lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aigner, Thomas" <>
Subject RE: Optimization
Date Fri, 07 Oct 2005 13:17:04 GMT
Thanks Erik, I tried the reverse index and it worked like a charm.
While I was doing this, we figured out a way to handle contains within
search and wildcard searches at the beginning.  I thought I would share
it with the community (and realized it handled the reverse index as


Tokens created:
What I do is if the search string is : 
	WORD*   I search for <WORD*  
	*WORD   I search for WORD*
	*WORD*  I search for WORD*
      WORD    I search for <WORD

With this technique, the search result time was decreased tremendously
for contains within and wildcard searches from the beginning.  The index
has become 5X as large and takes longer to build, but I'm willing to
sacrifice disk space and time for this huge benefit of speed.  Also, I
have taken the wildcard query completely out of the program now so
everything uses my customized analyzer.


-----Original Message-----
From: Erik Hatcher [] 
Sent: Wednesday, October 05, 2005 9:27 AM
Subject: Re: Optimization

On Oct 5, 2005, at 9:05 AM, Aigner, Thomas wrote:
>     Have a question.. Is there any obvious things that can be done
> to help speed up query lookups especially wildcard searches (i.e.
> *lamps).

Obvious?  Sort of.  *lamps needs to scan through _every_ single term  
in the index (for the specified field only, of course) because terms  
are lexicographically ordered.

If you reverse terms during analysis and lay them in the same  
position (increment 0) as the original token you'd end up with  
"spmal..." terms.  Now pre-process the query string and if there is a  
prefixed wildcard query, reverse it so that "*lamps" turns into  
"spmal*" and you will likely achieve a dramatic speed-up.

This is just one technique for dealing with prefixed wildcard  
queries.  There is more fun to be had with queries like *lamps*.  A  
technique I learned from the book Managing Gigabytes is to rotate  
terms through all their possible variations and index all of those,  
which also requires cleverness on the querying side of things.


To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message