lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fernando Wasylyszyn <>
Subject Re: Suggest search terms
Date Mon, 21 Feb 2011 20:11:28 GMT
I think that the idea that Uwe mentions is completely valid. Although it has a 
few disadvantages:

For example, what if you want to suggest "multiword suggestions" and in your 
index you have only "single word" tokens.

Query: Ferrari
Ideal suggestions: Ferrari 354 BT, Ferrari 355 C, Ferrari 356
Index have the tokens: Ferrari, 354, 355, 356, BT, C

De: Uwe Schindler <>
Enviado: lunes, 21 de febrero, 2011 15:29:35
Asunto: RE: Suggest search terms


I just have a suggestion to your first idea of enumerating terms, which is
very fast if done right:

> I'd like to suggest search terms to my users. My naïve approach would have
> been:
> After at least n characters have been typed (asynchronously) find terms in
> IndexReader.terms()  which "match"

Much easier is to use IR.terms() but wrap a PrefixTermEnum around it (it's
in search package). Then you simply iterate (please don't forget that the
enum is already positioned on the first term!!! If no such term exists, the
enum's term() returns null). Just use a "if (enum.term() != null) do { }
while (!=null && numberOfTermCollectex <= max)", with Lucene
trunk this is much better now, but with 3.x, you have to use this ugly


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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message