lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: Lucene 5 Custom FieldComparator
Date Thu, 13 Aug 2015 20:13:44 GMT
You have to index as Docvalues since 5.0 to do that type of query. FieldCache is gone, see
MultiFields does not help here, it is more to view the whole index as a single LeafReader
although it contains of multiple segments (LeafReaders). Its also used for merging, but user
code should not use it.

The doSetNextReader is provided in the API because the collecting of results is done per index
segment (means per LeafReader) and the document ids reported to collect() are relative to
those readers, not valid globally. In setNextReader you have to fetch the docvalues from the
index using LeafReader and access them later in the compare methods using the local docids.


P.S.: FieldCache is still available as a reader wrapper in misc modules 'uninverting' package,
but the API no longer returns arrays. You just get back a DocValues emulation, which is random
access. You still have to do this per index segment (setNextReader).

Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen

> -----Original Message-----
> From: Pablo Mincz []
> Sent: Thursday, August 13, 2015 5:35 PM
> To:
> Subject: Lucene 5 Custom FieldComparator
> Hi,
> I'm doing a migration from Lucene 3.6.1 to 5.2.1 and I have a custom
> FieldComparator that sort the search for availables discounts. For this, first I
> check that the date range is valid and later sort by the discount amount.
> I did this in Lucene 3.6.1 but now in 5.2.1 version, the FieldComparator has
> the method doSetNextReader that has a LeafReaderContext and I do not
> know how to read all the fields from the LeafReader because I did not
> indexed this field with DocValues.
> I tried with MultiFields but I got only one result instead of an array, and some
> values are Floats.
> Someone know how to do this?
> Thanks a lot for the help.
> Regards,
> Pablo.

View raw message