[sword-devel] fast searching support

Joachim Ansorg sword-devel@crosswire.org
Tue, 15 Aug 2000 22:53:54 +0000


Hi Troy!

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();
	}
}

for (ListKey &searchResultList = module->Search(text.latin1(), searchType, 
  searchParams, myScope); !searchResultList.Error(); searchResultList++)
{
	//handling with own classes, creating search result items of a list etc.
}

A bug: After I created the index using createSEarchFrameWork() it won' be 
registered until next restart! I mean that hasSearchFrameWork returns false 
until next restart.

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).



--Joachim

> OK,
> 	fixed a few bugs.  Any early testers should update their CVS tree and
> make clean; make
>
> 		-Troy.
>
> "Troy A. Griffitts" wrote:
> > OK Joachim ;)
> >
> >         I've added some basic search framework support and have optimized
> > a few search scenerios for the RawText driver (case insensitive,
> > multiword searches with a scope designated by a VerseKey).  You'll need
> > the latest CVS source to try it out.
> >
> > There is a utility: sword/utilities/mkfastmod that will create the
> > search framework for a module if it is supported for the module type.
> >
> > ***     THIS IS A REFERENCE IMPLEMENTATION.  There are others much more
> > capable than myself (Trevor! :) ) that could do a much better job.  This
> > example should make the sword aspects of the job less mystic.
> >
> > New/Augmented framework methods:
> >
> > virtual ListKey &SWModule::Search(const char *istr, int searchType = 0,
> > int flags = 0, SWKey *scope = 0, bool *justCheckIfSupported = 0);
> >
> >         justCheckIfSupported was added to allow one to see if THIS search
> > routine will perform the search.  This is not a check to see if the
> > search is ultimately supported (maybe by the base class).
> >
> > virtual char SWModule::createSearchFramework();
> >
> >         This will ask the module to build (or rebuild) any special search
> > framework that it supports.
> >
> > virtual bool SWModule::hasSearchFramework();
> >
> >         This allows one to check if the module driver supports a search
> > framework.
> >
> > virtual bool SWModule::isSearchOptimallySupported(const char *istr, int
> > searchType, int flags, SWKey *scope);
> >
> >         This allows one to check if the search will be handled in the
> > most optimized way (ie. if there is a search framework and it does not
> > handle this case, this will be false)
> >
> >         Let me know if it works! :)  It compiles :)  j/k  Also, if there
> > are any questions by anyone wishing to build a real search framework,
> > please ask!
> >
> >         -Troy.
> >
> > Joachim Ansorg wrote:
> > > Hi!
> > >
> > > My first article in this group!
> > >
> > > A really slow thing of SWORD is the searching part! In comparision with
> > > other programs it takes too long.
> > >
> > > Perhaps you noticed some months ago that Trevor Jenkins offered his
> > > help on this topic.
> > > But nothing happened.
> > >
> > > My question is: How do we get a more fast searching algorithm?
> > >
> > > -- Joachim