lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Goutham Tholpadi <>
Subject Analyzing suggester for many fields
Date Tue, 27 Aug 2013 13:19:25 GMT
Lucene Version : 4.4.0


I need to suggest terms to the user based on a query prefix typed in a
textbox. The terms suggested should exist in the index that will be
searched. I want to suggest terms from more than one field in the

I am trying to use for


Given the path to the index directory, I proceed as follows.
IndexReader ireader =
List<AtomicReaderContext> readercs = ireader.leaves();
for (AtomicReaderContext readerc : readercs) {
    Fields fields = readerc.reader().fields();
    for (String field : fields) {
        TermsEnum termsEnum = fields.terms(field).iterator(null);
        tfit = new TermFreqIteratorWrapper(termsEnum);  // OVERWRITE!
AnalyzingSuggester suggr = new AnalyzingSuggester(analyzer);;

In the line marked "OVERWRITE!", I am overwriting the term list from
one field with the term list from the next field. I want to aggregate
term lists obtained from different fields.

I could not find a way to instantiate TermFreqIterator without a
BytesRefIterator. The only way to get a BytesRefIterator seems to be
in the form of TermsEnum. Neither can be changed (i.e. appended to)
after instantiation.

How can I aggregate the TermsEnum lists from different fields so that
I can pass them together in one shot to build()? Alternatively, is
there a way to add term lists to the suggester after calling build()


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

View raw message