lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: Lucene Free Text Suggester, get only single tokens as suggestion!
Date Mon, 13 Oct 2014 10:12:52 GMT
The problem is, your Dictionary is enumerating the analyzed (by
WhitespaceAnalyzer) terms, so you will always only see a single token
suggested.

You could use KeywordAnalyzer instead, so that the entire string is a
single token.  But this bloats your index, so it's better to simply
build the suggester directly from your strings and skip putting them
into a Lucene index, unless you need them indexed for some reason...

Mike McCandless

http://blog.mikemccandless.com


On Mon, Oct 13, 2014 at 5:07 AM, andi rexha <a_rexha@hotmail.com> wrote:
> Hi!
> I have a field in an index for which I want to have a "free text suggestion". The field
is analyzed, storend  and term vector the field. I tried to use two approaches to get the
suggestions from the field.
>
> I have tried to apply the free text suggester with a dictionary like :
>
>
>              FreeTextSuggester freeTextSuggester = new FreeTextSuggester(new WhitespaceAnalyzer(),
new WhitespaceAnalyzer(), 2);
>              Dictionary dict = new LuceneDictionary(reader, field);
>              freeTextSuggester.build(dict);
>
>
>
> I have also tried a different approach, buy using the term vector elements for each document:
>
>              WFSTCompletionLookup wfstCompletionLookup = new WFSTCompletionLookup();
>              //it iterates over the term vector and is an InputIterator
>             TermVectorInputIterator termVectorInputIterator = new TermVectorInputIterator(reader,
field);
>             wfstCompletionLookup.build(termVectorInputIterator);
>
>
>
> I have an index with 916 documents, and approximately 32.000 terms, but I always get
as suggestion for a few characters input, single tokens suggestion, and not n-grams. Does
anybody have any suggestion about my problem?
>
> Thank you in advance!
>

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


Mime
View raw message