Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.util.search
Class FieldFilter

java.lang.Object
  extended by org.apache.lucene.search.Filter
      extended by com.jivesoftware.util.search.FieldFilter
All Implemented Interfaces:
java.io.Serializable

public class FieldFilter
extends org.apache.lucene.search.Filter

A Filter that restricts search results to Documents that match a set of specified Field values. For example, suppose you create a search index to make your catalog of widgets searchable. When indexing, you add a field to each Document called "color" that has one of the following values: "blue", "green", "yellow", or "red". Now suppose that a user is executing a query but only wants to see green widgets in the results. The following code snippet yields that behavior:

     //In this example, we assume the Searcher and Query are already defined.
     //Define a FieldFilter to only show green colored widgets.
     Field myFilter = new FieldFilter("color", "green");
     Hits queryResults = mySearcher.execute(myQuery, myFilter);
 

See Also:
Serialized Form

Constructor Summary
FieldFilter(java.lang.String field, java.lang.String value)
          Creates a new field filter.
FieldFilter(java.lang.String field, java.lang.String[] values)
          Creates a new field filter.
 
Method Summary
 java.util.BitSet bits(org.apache.lucene.index.IndexReader reader)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldFilter

public FieldFilter(java.lang.String field,
                   java.lang.String[] values)
Creates a new field filter. The name of the field and the values to filter on are specified. In order for a Document to pass this filter, it must:
  1. The given field must exist in the document.
  2. The field value in the Document must exactly match one of the given values.

Parameters:
field - the name of the field to filter on.
values - the possible values of the field that search results must match.

FieldFilter

public FieldFilter(java.lang.String field,
                   java.lang.String value)
Creates a new field filter. The name of the field and the value to filter on are specified. In order for a Document to pass this filter, it must:
  1. The given field must exist in the document.
  2. The field value in the Document must exactly match one of the given values.

Parameters:
field - the name of the field to filter on.
value - the value of the field that search results must match.
Method Detail

bits

public java.util.BitSet bits(org.apache.lucene.index.IndexReader reader)
                      throws java.io.IOException
Specified by:
bits in class org.apache.lucene.search.Filter
Throws:
java.io.IOException

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.