lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: How to access DocValues inside a customized collector?
Date Fri, 21 Sep 2018 10:54:27 GMT

in general your approach is right, but you have to do it correctly. It depends on the Collector
subclass you are using. The simplest is to subclass SimpleCollector:

There you have to override 2 methods:

doSetNextReader(LeafReaderContext context): Here you call *once* context.reader().getBinaryDocValues(String
field) and save the thing in a private member field "actReaderdocValues" of the collector

In collect(docId) you can then call actReaderdocValues.advanceExact(docId) and retrieve the
value. As collect is always called "in order", its safe to use advanceExact().

Important is: Don't get a new docvalues instance on each call and advanceExact()! This is
only needed for out of order! So in combination with an collector (like above) you get maximum
performance, as everything is per leaf reader and in order.


Uwe Schindler
Achterdiek 19, D-28357 Bremen

> -----Original Message-----
> From: Lisheng Zhang <>
> Sent: Friday, September 21, 2018 3:23 AM
> To:
> Subject: How to access DocValues inside a customized collector?
> we need to use binary DocValues (in a customized collector) added during
> indexing, i first tested in standard TopScoreDocCollector, it seems that we
> need to:
> LeafReaderContext => reader() => get binary iterator => advanced to correct
> location
> Is this the correct way or actually we have a better API (since we already
> in that docId it seems to me that the binary DocValues should be readily
> available?
> Also do we have a way to see directly indexed data (Luke seems obsolete,
> Marple does not work with lucene 7.4.0 yet)?
> Thanks very much for helps, Lisheng

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

View raw message