Query String Usage

edit

Fluent DSL example

edit
q
.QueryString(c => c
    .Name("named_query")
    .Boost(1.1)
    .Fields(f => f.Field(p => p.Description).Field("myOtherField"))
    .Query("hello world")
    .DefaultField(p => p.Description)
    .DefaultOperator(Operator.Or)
    .Analyzer("standard")
    .QuoteAnalyzer("quote-an")
    .AllowLeadingWildcard()
    .MaximumDeterminizedStates(2)
    .AutoGeneratePhraseQueries()
    .LowercaseExpendedTerms()
    .Locale("en_US")
    .UseDisMax()
    .EnablePositionIncrements()
    .Escape()
    .FuzzyPrefixLength(2)
    .FuzzyMaxExpansions(3)
    .FuzzyRewrite(MultiTermQueryRewrite.ConstantScore)
    .Rewrite(MultiTermQueryRewrite.ConstantScore)
    .Fuzziness(Fuzziness.Auto)
    .TieBreaker(1.2)
    .AnalyzeWildcard()
    .MinimumShouldMatch(2)
    .QuoteFieldSuffix("'")
    .Lenient()
    .Timezone("root")
)

Object Initializer syntax example

edit
new QueryStringQuery
{
    Fields = Field<Project>(p => p.Description).And("myOtherField"),
    Boost = 1.1,
    Name = "named_query",
    Query = "hello world",
    DefaultField = Field<Project>(p => p.Description),
    DefaultOperator = Operator.Or,
    Analyzer = "standard",
    QuoteAnalyzer = "quote-an",
    AllowLeadingWildcard = true,
    MaximumDeterminizedStates = 2,
    AutoGeneratePhraseQueries = true,
    LowercaseExpendedTerms = true,
    Locale = "en_US",
    UseDisMax = true,
    EnablePositionIncrements = true,
    Escape = true,
    FuzzyPrefixLength = 2,
    FuzzyMaxExpansions = 3,
    FuzzyMultiTermQueryRewrite = MultiTermQueryRewrite.ConstantScore,
    MultiTermQueryRewrite = MultiTermQueryRewrite.ConstantScore,
    Fuzziness = Fuzziness.Auto,
    TieBreaker = 1.2,
    AnalyzeWildcard = true,
    MinimumShouldMatch = 2,
    QuoteFieldSuffix = "'",
    Lenient = true,
    Timezone = "root"
}

Example json output.

{
  "query_string": {
    "_name": "named_query",
    "boost": 1.1,
    "query": "hello world",
    "default_field": "description",
    "default_operator": "or",
    "analyzer": "standard",
    "quote_analyzer": "quote-an",
    "allow_leading_wildcard": true,
    "lowercase_expanded_terms": true,
    "enable_position_increments": true,
    "fuzzy_max_expansions": 3,
    "fuzziness": "AUTO",
    "fuzzy_prefix_length": 2,
    "analyze_wildcard": true,
    "auto_generate_phrase_queries": true,
    "max_determinized_states": 2,
    "minimum_should_match": 2,
    "lenient": true,
    "locale": "en_US",
    "time_zone": "root",
    "fields": [
      "description",
      "myOtherField"
    ],
    "use_dis_max": true,
    "tie_breaker": 1.2,
    "rewrite": "constant_score",
    "fuzzy_rewrite": "constant_score",
    "quote_field_suffix": "'",
    "escape": true
  }
}