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")
    .DefaultOperator(Operator.Or)
    .Analyzer("standard")
    .QuoteAnalyzer("keyword")
    .AllowLeadingWildcard()
    .MaximumDeterminizedStates(2)
    .Escape()
    .FuzzyPrefixLength(2)
    .FuzzyMaxExpansions(3)
    .FuzzyRewrite(MultiTermQueryRewrite.ConstantScore)
    .Rewrite(MultiTermQueryRewrite.ConstantScore)
    .Fuzziness(Fuzziness.Auto)
    .TieBreaker(1.2)
    .AnalyzeWildcard()
    .MinimumShouldMatch(2)
    .QuoteFieldSuffix("'")
    .Lenient()
    .AutoGenerateSynonymsPhraseQuery(false)
)

Object Initializer syntax example

edit
new QueryStringQuery
{
    Fields = Field<Project>(p => p.Description).And("myOtherField"),
    Boost = 1.1,
    Name = "named_query",
    Query = "hello world",
    DefaultOperator = Operator.Or,
    Analyzer = "standard",
    QuoteAnalyzer = "keyword",
    AllowLeadingWildcard = true,
    MaximumDeterminizedStates = 2,
    Escape = true,
    FuzzyPrefixLength = 2,
    FuzzyMaxExpansions = 3,
    FuzzyRewrite = MultiTermQueryRewrite.ConstantScore,
    Rewrite = MultiTermQueryRewrite.ConstantScore,
    Fuzziness = Fuzziness.Auto,
    TieBreaker = 1.2,
    AnalyzeWildcard = true,
    MinimumShouldMatch = 2,
    QuoteFieldSuffix = "'",
    Lenient = true,
    AutoGenerateSynonymsPhraseQuery = false
}

Example json output.

{
  "query_string": {
    "_name": "named_query",
    "boost": 1.1,
    "query": "hello world",
    "default_operator": "or",
    "analyzer": "standard",
    "quote_analyzer": "keyword",
    "allow_leading_wildcard": true,
    "fuzzy_max_expansions": 3,
    "fuzziness": "AUTO",
    "fuzzy_prefix_length": 2,
    "analyze_wildcard": true,
    "max_determinized_states": 2,
    "minimum_should_match": 2,
    "lenient": true,
    "fields": [
      "description",
      "myOtherField"
    ],
    "tie_breaker": 1.2,
    "rewrite": "constant_score",
    "fuzzy_rewrite": "constant_score",
    "quote_field_suffix": "'",
    "escape": true,
    "auto_generate_synonyms_phrase_query": false
  }
}