When I have a multi-match query, what index analyzer gets applied to the query by default?

I am using a multi-match query on multi-fields as follows:

INDEX:

   "mappings": { "my_doc": { "properties": {
      "content": {
          "type": "text",
              "fields": {
                  "ngram": {
                      "type": "text",
                       "analyzer": "ngram_icu_analyzer"
                   },
                  "norm": {
                       "type": "text",
                       "analyzer": "icu_analyzer"
                   },
                  "phonetic": {
                        "type": "text",
                        "analyzer": "phonetic_analyzer"
                  },
                  "stem": {
                      "type": "text",
                       "analyzer": "stem_analyzer"
                  }
          },
         "analyzer": "preserve_analyzer"
        }
 }}}

QUERY:

{
    "query": {
        "multi_match" : {
            "query":    "this is a test", 
            "fields": [ "title^3", "content^3", "title.ngram",   "content.ngram"] 
        }
    }
}

What analyzer gets applied to which fields on the query? Will there be any analyzer applied? Will it be on a per-field basis? (e.g. for field title.ngram will the ngram_icu_analyzer be applied) Will the default analyzer for the field be applied? (preserve_analyzer).

In other words, do I need to specify a search analyzer in order to control how the query is analyzed?

Will it be on a per-field basis?

Yes. I believe so as the multi_match generates behind the scene match queries for each field (see best_fields default option: Multi-match query | Elasticsearch Guide [8.11] | Elastic).

The best_fields type generates a match query for each field and wraps them in a dis_max query, to find the single best matching field.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.