FileDocCategorySizeDatePackage
QueryWrapperFilter.javaAPI DocApache Lucene 2.2.02269Sat Jun 16 22:20:34 BST 2007org.apache.lucene.search

QueryWrapperFilter

public class QueryWrapperFilter extends Filter
Constrains search results to only match those which also match a provided query.

This could be used, for example, with a {@link RangeQuery} on a suitably formatted date field to implement date filtering. One could re-use a single QueryFilter that matches, e.g., only documents modified within the last week. The QueryFilter and RangeQuery would only need to be reconstructed once per day.

version
$Id:$

Fields Summary
private Query
query
Constructors Summary
public QueryWrapperFilter(Query query)
Constructs a filter which only matches documents matching query.

    this.query = query;
  
Methods Summary
public java.util.BitSetbits(org.apache.lucene.index.IndexReader reader)

    final BitSet bits = new BitSet(reader.maxDoc());

    new IndexSearcher(reader).search(query, new HitCollector() {
      public final void collect(int doc, float score) {
        bits.set(doc);  // set bit for hit
      }
    });
    return bits;
  
public booleanequals(java.lang.Object o)

    if (!(o instanceof QueryWrapperFilter))
      return false;
    return this.query.equals(((QueryWrapperFilter)o).query);
  
public inthashCode()

    return query.hashCode() ^ 0x923F64B9;
  
public java.lang.StringtoString()

    return "QueryWrapperFilter(" + query + ")";