In Lucene you have to use the new DocValues fields (available since 4.0) to 
sort on.

For backwards compatibility, you can still use the older "uninversion" hack 
(also known as "Field Cache"). In Lucene 5 and 6 this part was removed from 
Lucene Core. To sort, you have 2 options:

- Reindex your stuff with DocValues fields enabled. This new field type is 
optimized for random access as used by sorting. This is the recommended 
approach.

- Alternatively you can use UninvertingReader from the misc module and wrap 
your index reader. This "emulates" the DocValues APIs on indexes without 
DocValues. Internally it uses the old FieldCache code to do this. This has the 
same problems as earlier Lucene versions: Heavy heap usage and slow uninversion 
of field values. To use it you must wrap every segment of your index separately 
(e.g. by implementing FilterDirectoryReader) using 
https://lucene.apache.org/core/5_0_0/misc/org/apache/lucene/uninverting/UninvertingReader.html

Erick: Solr has UninvertingReader used by default in SolrIndexSearcher.

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: u...@thetaphi.de

> -----Original Message-----
> From: Torsten Krah [mailto:krah...@gmail.com]
> Sent: Monday, April 25, 2016 6:25 PM
> To: Erick Erickson <erickerick...@gmail.com>
> Cc: java-user <java-user@lucene.apache.org>
> Subject: Re: Lucene 5.0.0 - StringField and Sorting
> 
> Hi Erick,
> 
> i guess you've muddled the lists - this is lucenes one, not solr. I know
> how to define it in solr but that wasn't the question as i am using pure
> lucene and it did not work as expected from the javadocs there.
> 
> Cheers
> 
> Torsten
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org


---------------------------------------------------------------------
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