[sword-devel] python search with lucene indexes ?

Pierre Amadio pierre.amadio at libertysurf.fr
Tue Feb 13 09:43:07 MST 2007

Hi there.

Thanks to you, i have resolved my main python sword issue and am now
able to access sword module in the python2.5 that comes with maemo.

So, i have a nice little GUI application:


Now, the search feature is really time consuming. It tooks something
like 2 mn. During this time, the application is frozen (this is another
issue that i m trying to dealt with as well), so the faster the search
is, the better.

Chatting on irc, i have been told that using lucene indexes should make
search more effective.

So, i managed to package clucene for maemo as well as recompile sword
--with-lucene (this is not available on the web page yet, but i have it
on my local laptop). I have generated an index for my KJV module with 

mkfastmod KJV

Now, my question is...How am i supposed to use lucene indexes ?
I'm using python with the swig bindings.

Looking at sword-1.5.9/src/modules/swmodule.cpp i found:

 * SWModule::Search     - Searches a module for a string
 * ENT: istr            - string for which to search
 *      searchType      - type of search to perform
 *                              >=0 - regex
 *                              -1  - phrase
 *                              -2  - multiword
 *                              -3  - entryAttrib (eg.
 *                              Word//Lemma/G1234/)
 *                              -4  - clucene
 *      flags           - options flags for search
 *      justCheckIfSupported    - if set, don't search, only tell if
 *      this
 *                                                      function
 *                                                      supports
 *                                                      requested
 *                                                      search.
 * RET: ListKey set to verses that contain istr

It looks like all that is needed is to use '4' as an argument to the
search function, wich, in python should be in the module doSearch

I have attached to this mail a test case in python that try to find
occurences of 'knock' with different value for the second argument of
doSearch. I was expecting to have faster result when the value of this
argument was 4, but still, it takes me roughly 18 seconds on my laptop,
whatever the value of the second argument.

How faster is supposed to be the use of the lucene index ?

Any idea as to what i may do wrong ?

Have a nice day !

Pierre Amadio
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testsearch.py
Type: text/x-python
Size: 424 bytes
Desc: not available
Url : http://www.crosswire.org/pipermail/sword-devel/attachments/20070213/a9518205/attachment.py 

More information about the sword-devel mailing list