[sword-devel] fast searching support
Troy A. Griffitts
sword-devel@crosswire.org
Wed, 16 Aug 2000 16:30:52 -0700
> A very good thing this fast search!
:)
> Maybe I'm wrong, but at first gflances I think it's not faster than normal
> search before.
>
> I'm using this code and I think it's correct . Is it?
>
> if (!module->isSearchOptimallySupported( text.latin1(), searchType,
> searchParams, myScope) ) {
> //rebuild search framework if it's available
> if (module->hasSearchFramework()) {
> module->createSearchFramework();
> }
> }
Not quite, maybe we should rethink the functionality of these methods.
Please take some time to follow this logic closely as it can be very
confusing. I had a tough time coming up with appropriate methods and
probably did not do such a good job.
There are many states to consider:
Mod driver supports Module has framework Framework supports
a framework (A) built (B) search scenerio (C)
-------------------------------------------------------------------------
0 O O O
4.........X........................O.........................O
5 X O X
6.........X........................X.........................O
7 X X X
I believe you want to offer the option to the user to build the search
framework in situations 4 and 5-- condition (A) is true but condition
(B) is false. Your check:
if (!module->isSearchOptimallySupported( text.latin1(), searchType,
searchParams, myScope) ) {
tells you that a search is not handled by the optimum code. This
happens in scenerios 4, 5, 6. It is useful for telling the user that
their current search scenerio may take unusually long. SWModule::Search
returns true to the function isSearchOptimallySupported in the case that
there is no other framework to support the search. It is handled as
optimum as any other search on this module.
You next call seems to try to filter out scenerio 0, which is already
filtered out by the first call.
Instead, you should filter out the problem scenerio (6) with a call
like:
bool isSupported = false;
module->Search( text.latin1(), searchType, searchParams, myScope,
&isSupported );
if (isSupported)
module->createSearchFramework();
Maybe we should provide a method like, canSearchBeOptimized(...) that
takes care of both checks for the frontend programmer. Or maybe we
should just offer methods that return the condition of (A), (B), and (C)
as stated above and let the frontend programmer do all of the logic.
> I measured with and without index files and noticed taht searching takes
> evenlonger as before for often used words like god or jesus, but is very fast
> for words like "testing" (they appear very very rare).
You should notice an exponential increase in speed if the framework is
used. Remember, only for case-INSENSITIVE, multi-word searches bound by
the scope of a VerseKey. This seems to be the most popular search
scenerio.
Let me know how it goes. I'd love to hear if you get it working.
-Troy.