lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukas Ă–esterreicher <>
Subject Auto Completion search
Date Mon, 23 Jun 2008 15:24:22 GMT


I am trying to implement a search based on a search text in an index that
contains Track Title, Album Name or Artist Name information that delivers a
list or results that are suited for "auto completion" to make searching
easier for the user. This search is very performance critical. The real
search itself is done on a seperate index and has already been implemented.

Results should match any Title or Name that contains the sepecified text,
however only only matching at the start of a word. The PrefixQuery is
predestined for this, I think.
I created the index using a WhitespaceAnalyzer.

So for instance if I search for "Sing I"
it should match the texts
"If I Don't Sing I'll Cry", "Sing It" and "Sing It Again",
but not "I Sing".

The current solution I've come up with until now is use a
and create a TermQuery for all but the last token and a PrefixQuery for the
last token,
and combine this with AND (Occur.MUST).
So for instance "I Sing" would result in " AND*"
(I think,
I've never seen the string representation of the query).

When retrieving the results I check if the original query text is contained
within the returned (while ignoring cases), and only return it if
it is
the case.

I am not sure however if this is a good result, performance-wise.
Can you provide a better solution and/or comment on my current one.

The currend one is quite quick if no whitespace is contained in the search
but requests are many times slower if there are whitespaces (usually normal
in the search term.

View this message in context:
Sent from the Lucene - Java Users mailing list archive at

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

View raw message