Class SimpleQueryStringBuilder

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

    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 Detail

      • DEFAULT_LENIENT

        public static final boolean DEFAULT_LENIENT
        Default for using lenient query parsing.
        See Also:
        Constant Field Values
      • DEFAULT_ANALYZE_WILDCARD

        public static final boolean DEFAULT_ANALYZE_WILDCARD
        Default for wildcard analysis.
        See Also:
        Constant Field Values
      • DEFAULT_OPERATOR

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

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

        public static final int DEFAULT_FUZZY_PREFIX_LENGTH
        Default for prefix length in fuzzy queries.
        See Also:
        Constant Field Values
      • DEFAULT_FUZZY_MAX_EXPANSIONS

        public static final int DEFAULT_FUZZY_MAX_EXPANSIONS
        Default number of terms fuzzy queries will expand to.
        See Also:
        Constant Field Values
      • DEFAULT_FUZZY_TRANSPOSITIONS

        public static final boolean DEFAULT_FUZZY_TRANSPOSITIONS
        Default for using transpositions in fuzzy queries.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SimpleQueryStringBuilder

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