You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Antony Bowesman <ad...@thorntothehorn.org> on 2011/04/18 11:18:01 UTC

What doc id to use on IndexReader with SetNextReader

Migrating some code from 2.3.2 to 2.9.4 and I have custom Collectors.

Now there are multiple calls to collect and each call needs to adjust the passed 
doc id by docBase as given in SetNextReader.

However, if you want to fetch the document in the collector, what 
docId/IndexReader combination should be used.

Given that

collect(int doc)
setNextReader(IndexReader reader, int docBase)

I have tested the following two which seem to get the same document

Document d = searcher.getIndexReader.document(doc + docBase)
Document d = reader.document(doc)

Is this guaranteed to always be the case and how the APIs should be used?

Thanks
Antony

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


Re: What doc id to use on IndexReader with SetNextReader

Posted by Antony Bowesman <ad...@thorntothehorn.org>.
Thanks Uwe, I assumed as much.

On 18/04/2011 7:28 PM, Uwe Schindler wrote:
>> Document d = reader.document(doc)
>
> This is the correct way to do it.
>
> Uwe

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


RE: What doc id to use on IndexReader with SetNextReader

Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi,

> Document d = searcher.getIndexReader.document(doc + docBase)

This is of course working, but somehow useless as it transforms the ID two
times and that slows down a little bit. Inside collectors you should *only*
use the IndexReader and Scorer given by the setNextReader / setScorer calls.

> Document d = reader.document(doc)

This is the correct way to do it.

Uwe


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