lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <paul.elsc...@xs4all.nl>
Subject Re: Filtering after Query
Date Sat, 17 Dec 2005 17:27:05 GMT
On Saturday 17 December 2005 17:04, Cret Hummin wrote:
> Hi All,
> 
> When using Searcher.search(Query, Filter), and I use my own custom 
> filter, it appears I'm presented with /all/ the documents in the index, 
> i.e. in the method bits(IndexReader reader) from my custom Filter, the 
> value of reader.maxDoc() is always the number of documents in the index. 
> The same is true when do Searcher.search(FilteredQuery(Query, Filter)).
>
> Is it possible to filter /after/ the query has limited the number of 
> possible documents, /before/ returning a Hits collection?

The easiest way to do this is by adding a required clause to a BooleanQuery.
You might consider using a ConstantScoringQuery for this clause:
http://issues.apache.org/jira/browse/LUCENE-383

In case you really want to filter only the documents that match a query
you'll need to implement a filtering HitCollector and use it on the
lower level search API. 
An easier way to implement such a filtering HitCollector could be
by adding to it the search methods that return a Hits as an alternative
to Filter.
A disadvantage of this approach is that skipTo() cannot be used
to combine the filter and the query, see also here:
http://issues.apache.org/jira/browse/LUCENE-330

Regards,
Paul Elschot


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


Mime
View raw message