CommonQueryParserConfiguration (Lucene 10.5.1 queryparser API)
Description: declaration: package: org.apache.lucene.queryparser.flexible.standard, interface: CommonQueryParserConfiguration

Package org.apache.lucene.queryparser.flexible.standard

# Interface CommonQueryParserConfiguration

All Known Implementing Classes:
  `ComplexPhraseQueryParser`, `ExtendableQueryParser`, `MultiFieldQueryParser`, `PrecedenceQueryParser`, `QueryParser`, `QueryParserBase`, `StandardQueryParser`

public interface CommonQueryParserConfiguration
Configuration options common across queryparser implementations.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `getAllowLeadingWildcard()`
  `Analyzer`
  `getAnalyzer()`
  `boolean`
  `getEnablePositionIncrements()`
  `float`
  `getFuzzyMinSim()`
  Get the minimal similarity for fuzzy queries.
  `int`
  `getFuzzyPrefixLength()`
  Get the prefix length for fuzzy queries.
  `Locale`
  `getLocale()`
  Returns current locale, allowing access by subclasses.
  `MultiTermQuery.RewriteMethod`
  `getMultiTermRewriteMethod()`
  `int`
  `getPhraseSlop()`
  Gets the default slop for phrases.
  `TimeZone`
  `getTimeZone()`
  `void`
  `setAllowLeadingWildcard(boolean allowLeadingWildcard)`
  Set to `true` to allow leading wildcard characters.
  `void`
  `setDateResolution(DateTools.Resolution dateResolution)`
  Sets the default `DateTools.Resolution` used for certain field when no `DateTools.Resolution` is defined for this field.
  `void`
  `setEnablePositionIncrements(boolean enabled)`
  Set to `true` to enable position increments in result query.
  `void`
  `setFuzzyMinSim(float fuzzyMinSim)`
  Set the minimum similarity for fuzzy queries.
  `void`
  `setFuzzyPrefixLength(int fuzzyPrefixLength)`
  Set the prefix length for fuzzy queries.
  `void`
  `setLocale(Locale locale)`
  Set locale used by date range parsing.
  `void`
  `setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method)`
  By default QueryParser uses `MultiTermQuery.CONSTANT_SCORE_BLENDED_REWRITE` when creating a `PrefixQuery`, `WildcardQuery` or `TermRangeQuery`.
  `void`
  `setPhraseSlop(int defaultPhraseSlop)`
  Sets the default slop for phrases.
  `void`
  `setTimeZone(TimeZone timeZone)`

- ## Method Details

  - ### setAllowLeadingWildcard

    void setAllowLeadingWildcard(boolean allowLeadingWildcard)
    Set to `true` to allow leading wildcard characters.

    When set, `*` or `?` are allowed as the first character of a PrefixQuery and WildcardQuery. Note that this can produce very slow queries on big indexes.

    Default: false.

  - ### setEnablePositionIncrements

    void setEnablePositionIncrements(boolean enabled)
    Set to `true` to enable position increments in result query.

    When set, result phrase and multi-phrase queries will be aware of position increments. Useful when e.g. a StopFilter increases the position increment of the token that follows an omitted token.

    Default: false.

  - ### getEnablePositionIncrements

    boolean getEnablePositionIncrements()
    See Also:
      - `setEnablePositionIncrements(boolean)`

  - ### setMultiTermRewriteMethod

    void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method)
    By default QueryParser uses `MultiTermQuery.CONSTANT_SCORE_BLENDED_REWRITE` when creating a `PrefixQuery`, `WildcardQuery` or `TermRangeQuery`. This implementation is generally preferable because it a) Runs faster b) Does not have the scarcity of terms unduly influence score c) avoids any `IndexSearcher.TooManyClauses` exception. However, if your application really needs to use the old-fashioned `BooleanQuery` expansion rewriting and the above points are not relevant then use this to change the rewrite method. As another alternative, if you prefer all terms to be rewritten as a filter up-front, you can use `MultiTermQuery.CONSTANT_SCORE_REWRITE`. For more information on the different rewrite methods available, see `MultiTermQuery` documentation.

  - ### getMultiTermRewriteMethod

    MultiTermQuery.RewriteMethod getMultiTermRewriteMethod()
    See Also:
      - `setMultiTermRewriteMethod(org.apache.lucene.search.MultiTermQuery.RewriteMethod)`

  - ### setFuzzyPrefixLength

    void setFuzzyPrefixLength(int fuzzyPrefixLength)
    Set the prefix length for fuzzy queries. Default is 0.
    Parameters:
      `fuzzyPrefixLength` - The fuzzyPrefixLength to set.

  - ### setLocale

    void setLocale(Locale locale)
    Set locale used by date range parsing.

  - ### getLocale

    Locale getLocale()
    Returns current locale, allowing access by subclasses.

  - ### setTimeZone

    void setTimeZone(TimeZone timeZone)

  - ### getTimeZone

    TimeZone getTimeZone()

  - ### setPhraseSlop

    void setPhraseSlop(int defaultPhraseSlop)
    Sets the default slop for phrases. If zero, then exact phrase matches are required. Default value is zero.

  - ### getAnalyzer

    Analyzer getAnalyzer()

  - ### getAllowLeadingWildcard

    boolean getAllowLeadingWildcard()
    See Also:
      - `setAllowLeadingWildcard(boolean)`

  - ### getFuzzyMinSim

    float getFuzzyMinSim()
    Get the minimal similarity for fuzzy queries.

  - ### getFuzzyPrefixLength

    int getFuzzyPrefixLength()
    Get the prefix length for fuzzy queries.
    Returns:
      Returns the fuzzyPrefixLength.

  - ### getPhraseSlop

    int getPhraseSlop()
    Gets the default slop for phrases.

  - ### setFuzzyMinSim

    void setFuzzyMinSim(float fuzzyMinSim)
    Set the minimum similarity for fuzzy queries. Default is defined on `FuzzyQuery.defaultMaxEdits`.

  - ### setDateResolution

    void setDateResolution(DateTools.Resolution dateResolution)
    Sets the default `DateTools.Resolution` used for certain field when no `DateTools.Resolution` is defined for this field.
    Parameters:
      `dateResolution` - the default `DateTools.Resolution`