Multi Match Usage

edit

Fluent DSL example

edit
q
.MultiMatch(c => c
    .Fields(f => f.Field(p => p.Description).Field("myOtherField"))
    .Query("hello world")
    .Analyzer("standard")
    .Boost(1.1)
    .Slop(2)
    .Fuzziness(Fuzziness.Auto)
    .PrefixLength(2)
    .MaxExpansions(2)
    .Operator(Operator.Or)
    .MinimumShouldMatch(2)
    .FuzzyRewrite(MultiTermQueryRewrite.ConstantScoreBoolean)
    .TieBreaker(1.1)
    .CutoffFrequency(0.001)
    .Lenient()
    .ZeroTermsQuery(ZeroTermsQuery.All)
    .Name("named_query")
    .AutoGenerateSynonymsPhraseQuery(false)
)

Object Initializer syntax example

edit
new MultiMatchQuery
{
    Fields = Field<Project>(p => p.Description).And("myOtherField"),
    Query = "hello world",
    Analyzer = "standard",
    Boost = 1.1,
    Slop = 2,
    Fuzziness = Fuzziness.Auto,
    PrefixLength = 2,
    MaxExpansions = 2,
    Operator = Operator.Or,
    MinimumShouldMatch = 2,
    FuzzyRewrite = MultiTermQueryRewrite.ConstantScoreBoolean,
    TieBreaker = 1.1,
    CutoffFrequency = 0.001,
    Lenient = true,
    ZeroTermsQuery = ZeroTermsQuery.All,
    Name = "named_query",
    AutoGenerateSynonymsPhraseQuery = false
}

Example json output.

{
  "multi_match": {
    "_name": "named_query",
    "boost": 1.1,
    "query": "hello world",
    "analyzer": "standard",
    "fuzzy_rewrite": "constant_score_boolean",
    "fuzziness": "AUTO",
    "cutoff_frequency": 0.001,
    "prefix_length": 2,
    "max_expansions": 2,
    "slop": 2,
    "lenient": true,
    "tie_breaker": 1.1,
    "minimum_should_match": 2,
    "operator": "or",
    "fields": [
      "description",
      "myOtherField"
    ],
    "zero_terms_query": "all",
    "auto_generate_synonyms_phrase_query": false
  }
}

Multi match with boost usage

edit

Fluent DSL example

edit
q
.MultiMatch(c => c
    .Fields(Field<Project>(p => p.Description, 2.2).And("myOtherField^0.3"))
    .Query("hello world")
)

Object Initializer syntax example

edit
new MultiMatchQuery
{
    Fields = Field<Project>(p => p.Description, 2.2).And("myOtherField^0.3"),
    Query = "hello world",
}

Example json output.

{
  "multi_match": {
    "query": "hello world",
    "fields": [
      "description^2.2",
      "myOtherField^0.3"
    ]
  }
}

Multi match with no fields specified

edit

Starting with Elasticsearch 6.1.0+, it’s possible to send a Multi Match query without providing any fields. When no fields are provided the Multi Match query will use the fields defined in the index setting index.query.default_field (which in turns defaults to *).

Fluent DSL example

edit
q
.MultiMatch(c => c
    .Query("hello world")
)

Object Initializer syntax example

edit
new MultiMatchQuery
{
    Query = "hello world",
}

Example json output.

{
  "multi_match": {
    "query": "hello world"
  }
}