Multi_match query

I have the following query to match firstname or lastname

let searchQuery = {
          "query": {
            "bool": {
              "must": {
                  "multi_match": {
                    "query":      key,
                    "fields": ["firstName", "lastName"]
                  }
                },
              "filter": {
                "term": {
                  "listId": self.listId
                }
              }
            }       
          }
};

Say, if the name is Brian Adams, it matches for Brian or Adams. I want to match it partially also . It should match for Bri . or Ada
Can anyone suggest change in the query to achieve the same?

There are a few ways to achieve this. One good way is to use NGram Tokenizer for these fields.

Probably edge ngrams for your specific example. And depending on your coverage vs accuracy tolerance you could use the snowball analyser. Then throw in a frequency cutover to your match query to speed up processing.

1 Like

Thank you.

can we use Ngram tokenizer for even not_analysed fields, specifying analyser at search time?
Can you please share an example?

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