# Multi\_match query

**URL:** <https://discuss.elastic.co/t/multi-match-query/140879>\
**Category:** Elasticsearch\
**Created:** [July 20, 2018, 11:14am UTC](https://discuss.elastic.co/t/multi-match-query/140879 "2018-07-20T11:14:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vadiraj\_bidarahalli](https://avatars.discourse-cdn.com/v4/letter/v/7ea924/32.png) [@vadiraj\_bidarahalli](https://discuss.elastic.co/u/vadiraj_bidarahalli)\
**Post date:** [July 20, 2018, 11:14am UTC](https://discuss.elastic.co/t/multi-match-query/140879/1 "2018-07-20T11:14:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [July 21, 2018, 10:58pm UTC](https://discuss.elastic.co/t/multi-match-query/140879/2 "2018-07-21T22:58:48Z")

</div>

There are a few ways to achieve this. One good way is to use [NGram Tokenizer](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/analysis-ngram-tokenizer.html) for these fields.

---

<div class="post-metadata">

**Author:** ![Johnnycc1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johnnycc1/32/26069_2.png) [@Johnnycc1](https://discuss.elastic.co/u/Johnnycc1)\
**Post date:** [July 22, 2018, 5:09am UTC](https://discuss.elastic.co/t/multi-match-query/140879/3 "2018-07-22T05:09:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vadiraj\_bidarahalli](https://avatars.discourse-cdn.com/v4/letter/v/7ea924/32.png) [@vadiraj\_bidarahalli](https://discuss.elastic.co/u/vadiraj_bidarahalli)\
**Post date:** [July 24, 2018, 1:47am UTC](https://discuss.elastic.co/t/multi-match-query/140879/4 "2018-07-24T01:47:17Z")

</div>

Thank you.

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 21, 2018, 1:47am UTC](https://discuss.elastic.co/t/multi-match-query/140879/5 "2018-08-21T01:47:18Z")

</div>

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