org.apache.lucene.queryParser
Class QueryParserTestBase.QPTestParser

java.lang.Object
  extended by org.apache.lucene.queryParser.QueryParser
      extended by org.apache.lucene.queryParser.QueryParserTestBase.QPTestParser
All Implemented Interfaces:
QueryParserConstants
Enclosing class:
QueryParserTestBase

public static class QueryParserTestBase.QPTestParser
extends QueryParser

Test QueryParser that does not allow fuzzy or wildcard queries.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.lucene.queryParser.QueryParser
QueryParser.Operator
 
Field Summary
 
Fields inherited from class org.apache.lucene.queryParser.QueryParser
AND_OPERATOR, jj_nt, OR_OPERATOR, token, token_source
 
Fields inherited from interface org.apache.lucene.queryParser.QueryParserConstants
_ESCAPED_CHAR, _NUM_CHAR, _QUOTED_CHAR, _TERM_CHAR, _TERM_START_CHAR, _WHITESPACE, AND, Boost, CARAT, COLON, DEFAULT, EOF, FUZZY_SLOP, LPAREN, MINUS, NOT, NUMBER, OR, PLUS, PREFIXTERM, QUOTED, RangeEx, RANGEEX_END, RANGEEX_GOOP, RANGEEX_QUOTED, RANGEEX_START, RANGEEX_TO, RangeIn, RANGEIN_END, RANGEIN_GOOP, RANGEIN_QUOTED, RANGEIN_START, RANGEIN_TO, RPAREN, STAR, TERM, tokenImage, WILDTERM
 
Constructor Summary
QueryParserTestBase.QPTestParser(String f, Analyzer a)
           
 
Method Summary
protected  Query getFuzzyQuery(String field, String termStr, float minSimilarity)
          Factory method for generating a query (similar to QueryParser.getWildcardQuery(java.lang.String, java.lang.String)).
protected  Query getWildcardQuery(String field, String termStr)
          Factory method for generating a query.
 
Methods inherited from class org.apache.lucene.queryParser.QueryParser
addClause, Clause, Conjunction, disable_tracing, enable_tracing, escape, generateParseException, getAllowLeadingWildcard, getAnalyzer, getAutoGeneratePhraseQueries, getBooleanQuery, getBooleanQuery, getDateResolution, getDefaultOperator, getEnablePositionIncrements, getField, getFieldQuery, getFieldQuery, getFieldQuery, getFuzzyMinSim, getFuzzyPrefixLength, getLocale, getLowercaseExpandedTerms, getMultiTermRewriteMethod, getNextToken, getPhraseSlop, getPrefixQuery, getRangeCollator, getRangeQuery, getToken, main, Modifiers, newBooleanClause, newBooleanQuery, newFuzzyQuery, newMatchAllDocsQuery, newMultiPhraseQuery, newPhraseQuery, newPrefixQuery, newRangeQuery, newTermQuery, newWildcardQuery, parse, Query, ReInit, ReInit, setAllowLeadingWildcard, setAutoGeneratePhraseQueries, setDateResolution, setDateResolution, setDefaultOperator, setEnablePositionIncrements, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setLowercaseExpandedTerms, setMultiTermRewriteMethod, setPhraseSlop, setRangeCollator, Term, TopLevelQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryParserTestBase.QPTestParser

public QueryParserTestBase.QPTestParser(String f,
                                        Analyzer a)
Method Detail

getFuzzyQuery

protected Query getFuzzyQuery(String field,
                              String termStr,
                              float minSimilarity)
                       throws ParseException
Description copied from class: QueryParser
Factory method for generating a query (similar to QueryParser.getWildcardQuery(java.lang.String, java.lang.String)). Called when parser parses an input term token that has the fuzzy suffix (~) appended.

Overrides:
getFuzzyQuery in class QueryParser
Parameters:
field - Name of the field query will use.
termStr - Term token to use for building term for the query
Returns:
Resulting Query built for the term
Throws:
ParseException - throw in overridden method to disallow

getWildcardQuery

protected Query getWildcardQuery(String field,
                                 String termStr)
                          throws ParseException
Description copied from class: QueryParser
Factory method for generating a query. Called when parser parses an input term token that contains one or more wildcard characters (? and *), but is not a prefix term token (one that has just a single * character at the end)

Depending on settings, prefix term may be lower-cased automatically. It will not go through the default Analyzer, however, since normal Analyzers are unlikely to work properly with wildcard templates.

Can be overridden by extending classes, to provide custom handling for wildcard queries, which may be necessary due to missing analyzer calls.

Overrides:
getWildcardQuery in class QueryParser
Parameters:
field - Name of the field query will use.
termStr - Term token that contains one or more wild card characters (? or *), but is not simple prefix term
Returns:
Resulting Query built for the term
Throws:
ParseException - throw in overridden method to disallow