# Part of string multi\_match bool

**URL:** <https://discuss.elastic.co/t/part-of-string-multi-match-bool/212644>\
**Category:** Elasticsearch\
**Created:** [December 20, 2019, 10:27am UTC](https://discuss.elastic.co/t/part-of-string-multi-match-bool/212644 "2019-12-20T10:27:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajouve](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@ajouve](https://discuss.elastic.co/u/ajouve)\
**Post date:** [December 20, 2019, 10:27am UTC](https://discuss.elastic.co/t/part-of-string-multi-match-bool/212644/1 "2019-12-20T10:27:27Z")

</div>

I just duplicated mu customer database into Elasticsearch for faster result.

On my listing page I have a search field to search any string into my customer db. the search should be able to match a result on email, first name, last name, id and phone.

I created an `nGram` filter to be able to match only parts of query

```auto
ES.client.indices.putSettings({
            index: `customer`,
            body: {
                analysis : {
                    index_analyzer: {
                        my_index_analyzer: {
                            type: "custom",
                            tokenizer: "standard",
                            filter: ["lowercase", "mynGram"]
                        }
                      },
                      search_analyzer: {
                        my_search_analyzer: {
                            type: "custom",
                            tokenizer: "standard",
                            filter: ["standard", "lowercase", "mynGram"]
                        }
                      },
                      filter: {
                        mynGram: {
                            type: "nGram",
                            min_gram: 2,
                            max_gram: 30
                        }
                      }
                },
                max_ngram_diff: 30
            }
        })

```

and my query is

```auto
{
   "index":"customer",
   "pageNum":1,
   "perPage":20,
   "query":{
      "bool":{
         "must":[
            {
               "bool":{
                  "should":[
                     {
                        "match":{
                           "organizationId":"org_1"
                        }
                     },
                     {
                        "match":{
                           "organizationId":"org_2"
                        }
                     }
                  ]
               }
            },
            {
               "multi_match":{
                  "fields":[
                     "id",
                     "email",
                     "firstName",
                     "lastName",
                     "phone"
                  ],
                  "query":"loc"
               }
            }
         ]
      }
   },
   "sort":{
      "createdAt":{
         "order":"desc"
      }
   }
}

```

But this is not working as I want.

For example one of my emails is `test@geo.loc` and if I search for `loc` I have no result.

I made another test with 4 emails `test@geo.loc` `test1@test.com` `test2@test.com` `test@test.com`. Looking for `test` it only returns `test@geo.loc` and `test@test.com` should return all the results

Other test one of the phones number is `2211111111` if I am looking for `1111` I have no result but `2211111111` works

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 20, 2019, 12:43pm UTC](https://discuss.elastic.co/t/part-of-string-multi-match-bool/212644/2 "2019-12-20T12:43:46Z")

</div>

try using the [analyze API](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/indices-analyze.html) with the email address against both analyzers in order to figure out how data is put into the inverted index.

also a full blown example including index creation, mapping configuration, document indexing would probably help in order to reproduce the issue.

Thank you!

---

<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:** [January 17, 2020, 12:55pm UTC](https://discuss.elastic.co/t/part-of-string-multi-match-bool/212644/3 "2020-01-17T12:55:32Z")

</div>

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