Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.queryparser.analyzing
Class AnalyzingQueryParser

    java.lang.Object
      org.apache.lucene.queryparser.classic.QueryParserBase
          org.apache.lucene.queryparser.classic.QueryParser
              org.apache.lucene.queryparser.analyzing.AnalyzingQueryParser

All Implemented Interfaces:
  QueryParserConstants, CommonQueryParserConfiguration

    public class AnalyzingQueryParser

extends QueryParser

Overrides Lucene's default QueryParser so that Fuzzy-, Prefix-, Range-, and WildcardQuerys are also passed through the given analyzer, but wildcard characters `*` and `?` don't get removed from the search terms.

Warning: This class should only be used with analyzers that do not use stopwords or that add tokens. Also, several stemming analyzers are inappropriate: for example, GermanAnalyzer will turn `Häuser` into `hau`, but `H?user` will become `h?user` when using this parser and thus no match would be found (i.e. using this parser will be no improvement over QueryParser in such cases).

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.lucene.queryparser.classic.QueryParser
`QueryParser.Operator`

Nested classes/interfaces inherited from class org.apache.lucene.queryparser.classic.QueryParserBase
`QueryParserBase.MethodRemovedUseAnother`

Field Summary

Fields inherited from class org.apache.lucene.queryparser.classic.QueryParser
`jj_nt, token, token_source`

Fields inherited from class org.apache.lucene.queryparser.classic.QueryParserBase
`AND_OPERATOR, OR_OPERATOR`

Fields inherited from interface org.apache.lucene.queryparser.classic.QueryParserConstants
`_ESCAPED_CHAR, _NUM_CHAR, _QUOTED_CHAR, _TERM_CHAR, _TERM_START_CHAR, _WHITESPACE, AND, BAREOPER, Boost, CARAT, COLON, DEFAULT, EOF, FUZZY_SLOP, LPAREN, MINUS, NOT, NUMBER, OR, PLUS, PREFIXTERM, QUOTED, Range, RANGE_GOOP, RANGE_QUOTED, RANGE_TO, RANGEEX_END, RANGEEX_START, RANGEIN_END, RANGEIN_START, REGEXPTERM, RPAREN, STAR, TERM, tokenImage, WILDTERM`

Constructor Summary
`AnalyzingQueryParser(Version matchVersion, String field, Analyzer analyzer)`

Method Summary
`protected String` | `analyzeSingleChunk(String field, String termStr, String chunk)` Returns the analyzed form for the given chunk If the analyzer produces more than one output token from the given chunk, a ParseException is thrown.
`protected Query` | `getFuzzyQuery(String field, String termStr, float minSimilarity)` Called when parser parses an input term that has the fuzzy suffix (~) appended.
`protected Query` | `getPrefixQuery(String field, String termStr)` Called when parser parses an input term that uses prefix notation; that is, contains a single '*' wildcard character as its last character.
`protected Query` | `getWildcardQuery(String field, String termStr)` Called when parser parses an input term that contains one or more wildcard characters (like `*`), but is not a prefix term (one that has just a single `*` character at the end).

Methods inherited from class org.apache.lucene.queryparser.classic.QueryParser
`Clause, Conjunction, disable_tracing, enable_tracing, generateParseException, getNextToken, getToken, Modifiers, Query, ReInit, ReInit, Term, TopLevelQuery`

Methods inherited from class org.apache.lucene.queryparser.classic.QueryParserBase
`addClause, analyzeMultitermTerm, escape, getAllowLeadingWildcard, getAnalyzer, getAnalyzeRangeTerms, getAutoGeneratePhraseQueries, getBooleanQuery, getBooleanQuery, getDateResolution, getDefaultOperator, getEnablePositionIncrements, getField, getFieldQuery, getFieldQuery, getFuzzyMinSim, getFuzzyPrefixLength, getLocale, getLowercaseExpandedTerms, getMultiTermRewriteMethod, getPhraseSlop, getRangeQuery, getRegexpQuery, getTimeZone, init, newBooleanClause, newBooleanQuery, newFieldQuery, newFuzzyQuery, newMatchAllDocsQuery, newMultiPhraseQuery, newPhraseQuery, newPrefixQuery, newRangeQuery, newRegexpQuery, newTermQuery, newWildcardQuery, parse, setAllowLeadingWildcard, setAnalyzeRangeTerms, setAutoGeneratePhraseQueries, setDateResolution, setDateResolution, setDefaultOperator, setEnablePositionIncrements, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setLowercaseExpandedTerms, setMultiTermRewriteMethod, setPhraseSlop, setTimeZone`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AnalyzingQueryParser

    public AnalyzingQueryParser(Version matchVersion,
                                String field,
                                Analyzer analyzer)

Method Detail

### getWildcardQuery

    protected Query getWildcardQuery(String field,
                                     String termStr)
                              throws ParseException

  Called when parser parses an input term that contains one or more wildcard characters (like `*`), but is not a prefix term (one that has just a single `*` character at the end).

  Example: will be called for `H?user` or for `H*user`.

  Depending on analyzer and settings, a wildcard term may (most probably will) be lower-cased automatically. It will go through the default Analyzer.

  Overrides super class, by passing terms through analyzer.

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

### getPrefixQuery

    protected Query getPrefixQuery(String field,
                                   String termStr)
                            throws ParseException

  Called when parser parses an input term that uses prefix notation; that is, contains a single '*' wildcard character as its last character. Since this is a special case of generic wildcard term, and such a query can be optimized easily, this usually results in a different query object.

  Depending on analyzer and settings, a prefix term may (most probably will) be lower-cased automatically. It will go through the default Analyzer.

  Overrides super class, by passing terms through analyzer.

  Overrides:
    `getPrefixQuery` in class `QueryParserBase`
  Parameters:
    `field` - Name of the field query will use.
    `termStr` - Term to use for building term for the query (without trailing '*' character!)
  Returns:
    Resulting `Query` built for the term
  Throws:
    `ParseException` - throw in overridden method to disallow

### getFuzzyQuery

    protected Query getFuzzyQuery(String field,
                                  String termStr,
                                  float minSimilarity)
                           throws ParseException

  Called when parser parses an input term that has the fuzzy suffix (~) appended.

  Depending on analyzer and settings, a fuzzy term may (most probably will) be lower-cased automatically. It will go through the default Analyzer.

  Overrides super class, by passing terms through analyzer.

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

### analyzeSingleChunk

    protected String analyzeSingleChunk(String field,
                                        String termStr,
                                        String chunk)
                                 throws ParseException

  Returns the analyzed form for the given chunk If the analyzer produces more than one output token from the given chunk, a ParseException is thrown.

  Parameters:
    `field` - The target field
    `termStr` - The full term from which the given chunk is excerpted
    `chunk` - The portion of the given termStr to be analyzed
  Returns:
    The result of analyzing the given chunk
  Throws:
    `ParseException` - when analysis returns other than one output token

Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.