de.pangaea.metadataportal.search
Class FieldCheckingQuery

java.lang.Object
  extended by org.apache.lucene.search.Query
      extended by de.pangaea.metadataportal.search.FieldCheckingQuery
All Implemented Interfaces:
Serializable, Cloneable

public final class FieldCheckingQuery
extends Query

Low-level implementation of a Lucene Query that is needed by SearchService.newTextQuery(java.lang.String, java.lang.String, org.apache.lucene.queryParser.QueryParser.Operator) to parse query strings that are specific to one field. When a query string is assigned to a specific field, the user should not be allowed to use prefixes to reference other field names in his query string. SearchService wraps the parsed query string with this "filter". In the rewrite(org.apache.lucene.index.IndexReader) method (when query is expanded to native queries) it checks for terms with foreign field names and throws an exception if one was found.

Author:
Uwe Schindler
See Also:
Serialized Form

Constructor Summary
FieldCheckingQuery(String field, Query query)
          Constructor that wraps a query with a check for a specific field name.
 
Method Summary
 boolean equals(Object o)
           
 float getBoost()
          Delegated to wrapped Query
 Query getQuery()
          Returns the wrapped query.
 int hashCode()
           
 Query rewrite(IndexReader reader)
          Expands query to native queries by calling the rewrite-method of the wrapped query.
 void setBoost(float b)
          Sets the boost for this query clause to b.
 String toString(String field)
           
 
Methods inherited from class org.apache.lucene.search.Query
clone, combine, createWeight, extractTerms, getSimilarity, mergeBooleanQueries, toString, weight
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FieldCheckingQuery

public FieldCheckingQuery(String field,
                          Query query)
Constructor that wraps a query with a check for a specific field name.

Method Detail

getQuery

public Query getQuery()
Returns the wrapped query.


toString

public String toString(String field)
Specified by:
toString in class Query

equals

public final boolean equals(Object o)
Overrides:
equals in class Query

hashCode

public final int hashCode()
Overrides:
hashCode in class Query

rewrite

public Query rewrite(IndexReader reader)
              throws IOException
Expands query to native queries by calling the rewrite-method of the wrapped query. After that it extracts all terms in the query and checks the used field names.

Overrides:
rewrite in class Query
Throws:
IllegalArgumentException - if an invalid field name was detected.
IOException

setBoost

public void setBoost(float b)
Sets the boost for this query clause to b. Delegated to wrapped Query.

Overrides:
setBoost in class Query

getBoost

public float getBoost()
Delegated to wrapped Query

Overrides:
getBoost in class Query


Copyright ©2007-2011 panFMP Developers c/o Uwe Schindler