Class SimpleQueryStringBuilder

All Implemented Interfaces:
NamedWriteable, Writeable, QueryBuilder, Rewriteable<QueryBuilder>, ToXContent, ToXContentObject

public class SimpleQueryStringBuilder extends AbstractQueryBuilder<SimpleQueryStringBuilder>
SimpleQuery is a query parser that acts similar to a query_string query, but won't throw exceptions for any weird string syntax. It supports the following:
  • '+' specifies AND operation: token1+token2
  • '|' specifies OR operation: token1|token2
  • '-' negates a single token: -token0
  • '"' creates phrases of terms: "term1 term2 ..."
  • '*' at the end of terms specifies prefix query: term*
  • '(' and ')' specifies precedence: token1 + (token2 | token3)
  • '~N' at the end of terms specifies fuzzy query: term~1
  • '~N' at the end of phrases specifies near/slop query: "term1 term2"~5

See: SimpleQueryStringQueryParser for more information.

This query supports these options:

Required: query - query text to be converted into other queries

Optional: analyzer - anaylzer to be used for analyzing tokens to determine which kind of query they should be converted into, defaults to "standard" default_operator - default operator for boolean queries, defaults to OR fields - fields to search, defaults to _all if not set, allows boosting a field with ^n For more detailed explanation of the query string syntax see also the online documentation.

  • Field Details


      public static final boolean DEFAULT_LENIENT
      Default for using lenient query parsing.
      See Also:

      public static final boolean DEFAULT_ANALYZE_WILDCARD
      Default for wildcard analysis.
      See Also:

      public static final Operator DEFAULT_OPERATOR
      Default for default operator to use for linking boolean clauses.

      public static final int DEFAULT_FLAGS
      Default for search flags to use.

      public static final int DEFAULT_FUZZY_PREFIX_LENGTH
      Default for prefix length in fuzzy queries.
      See Also:

      public static final int DEFAULT_FUZZY_MAX_EXPANSIONS
      Default number of terms fuzzy queries will expand to.
      See Also:

      public static final boolean DEFAULT_FUZZY_TRANSPOSITIONS
      Default for using transpositions in fuzzy queries.
      See Also:
    • NAME

      public static final String NAME
      Name for (de-)serialization.
      See Also:
  • Constructor Details

    • SimpleQueryStringBuilder

      public SimpleQueryStringBuilder(String queryText)
      Construct a new simple query with this query string.
    • SimpleQueryStringBuilder

      public SimpleQueryStringBuilder(StreamInput in) throws IOException
      Read from a stream.
  • Method Details