You can't easily change the order in which terms are enumerated from
the index.  They are stored in unicode code point sort order, and then
TermEnum reads them back.

You'll have to do your own buffering & collation on top of
TermEnum.... which if you have alot of terms, and you really need all
of them, sorted, could consume mucho RAM.

SortComparatorSource/FieldComparatorSource is only used for sorting
hits during searching.

Mike

On Thu, Nov 12, 2009 at 9:45 AM, Jean-Claude Dauphin
<jc.daup...@gmail.com> wrote:
> Dear all,
>
> I am pretty sure it's trivial and I apologize for raising this issue.
>
> I wish to access the index in the order driven by:
>   Term+"Field name"+Frequency or
>   Frequency+Term+"Field Name".
>
> I read the terms in the order driven by "Field name"+Term+°Frequency as
> follow:
>
>  Directory fsd = FSDirectory.open(indexLoc_,
> NoLockFactory.getNoLockFactory());
>  IndexReader reader = new TermIndexReader(IndexReader.open(fsd, true));
>
>  TermEnum     terms  = reader.terms();
>  while (terms.next) {
>    Term term     = terms.term();
>    int  termFreq = terms.docFreq();
>    v.add(new DictionaryTerm(term, termFreq));
>  }
>
>   It works fine, but how to change the reading order?
>   Can I use a custom SortComparatorSource class?
>
>   Any advice or code example would be appreciated
>
>   Best,
>
>  JC
>

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

Reply via email to