[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lucene-user
Subject:    Re: Suggest search terms
From:       Fernando Wasylyszyn <ferwasy () yahoo ! com ! ar>
Date:       2011-02-22 12:12:02
Message-ID: 18813.54129.qm () web130106 ! mail ! mud ! yahoo ! com
[Download RAW message or body]


Well, actually it depends....
If your suggestion terms corresponds with the terms in your "main" index, then 
you can use TermEnum#docFreq()+
Otherwise, if you develop a separate index for the suggestions (that do not 
correspond with the terms in your main index), then you just can add a 
calculated field with the number of documents that contain the suggestion, 
something like:

Document:
    "suggestion" field: "Ferrari 455 GT"
    "docCount" field: 20

As you control the updates in the suggestions index, this can be achieved in 
each update of the main index.

Regards.
Fernando.




________________________________
De: Simon Willnauer <simon.willnauer@googlemail.com>
Para: java-user@lucene.apache.org
Enviado: martes, 22 de febrero, 2011 8:29:36
Asunto: Re: Suggest search terms

On Tue, Feb 22, 2011 at 11:23 AM, Clemens Wyss <clemensdev@mysign.ch> wrote:
> Fernando, Uwe thanks for your suggestions.
> Is it possible to get the number of "hits" per term?
> ferrari (125)
> lamborghini (34)
> ...

I think you can just call TermEnum#docFreq(), no?

simon
>
>> -----Ursprüngliche Nachricht-----
>> Von: Fernando Wasylyszyn [mailto:ferwasy@yahoo.com.ar]
>> Gesendet: Montag, 21. Februar 2011 21:11
>> An: java-user@lucene.apache.org
>> Betreff: Re: Suggest search terms
>>
>> 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 <uwe@thetaphi.de>
>> Para: java-user@lucene.apache.org
>> Enviado: lunes, 21 de febrero, 2011 15:29:35
>> Asunto: RE: Suggest search terms
>>
>> Hi,
>>
>> 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
>> (enum.next()!=null && numberOfTermCollectex <= max)", with Lucene
>> trunk this is much better now, but with 3.x, you have to use this ugly
>> iteration.
>>
>> Uwe
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


      

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic