lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Reuschling <>
Subject Filter for searching in result lists with 2.9
Date Fri, 16 Oct 2009 20:25:04 GMT
Hi guys,

in our app we gives the possibility to search inside a set of documents, which
is the result list of a former search. Thus, someone can shrink down a search
according different criterias.

For this, we implemented a simple Filter that simply gets a TopDocs Object and
creates a bitSet out of the document numbers:

class SearchInResultsFilter extends Filter
        private BitSet bitSet;

        public SearchInResultsFilter(TopDocs topDocs)
            bitSet = new BitSet(topDocs.scoreDocs.length);
            for (ScoreDoc scoreDoc : topDocs.scoreDocs)

        public BitSet bits(IndexReader reader) throws IOException
            return bitSet;

With Lucene 2.9, the reader object given in bits(..) is not the 'big reader',
but some kind of subreader, i.e. a SegmentReader. Thus, the document ids of
the topDocs and this object are not compatible anymore.
I think, in the new, non-deprecated 'DocIdSet getDocIdSet(IndexReader reader)'
will be the same SegmentReader.

I solved a similar scenario in our custom FieldComparator, by recognizing the
reader-specific docbase given in the method
'public void setNextReader(IndexReader reader, int docBase)'

But inside Filter, I don't have such a nice method. What is the trick?

Thanks for all potential hints


View raw message