# Problem with Arrays in Elastic Search

**URL:** <https://discuss.elastic.co/t/problem-with-arrays-in-elastic-search/122920>\
**Category:** Elasticsearch\
**Created:** [March 7, 2018, 4:14pm UTC](https://discuss.elastic.co/t/problem-with-arrays-in-elastic-search/122920 "2018-03-07T16:14:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gopala\_Krishna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gopala_krishna/32/28535_2.png) [@Gopala\_Krishna](https://discuss.elastic.co/u/Gopala_Krishna)\
**Post date:** [March 7, 2018, 4:14pm UTC](https://discuss.elastic.co/t/problem-with-arrays-in-elastic-search/122920/1 "2018-03-07T16:14:29Z")

</div>

Hello,

So, I am writing a custom autocomplete using elastic search.

Version 2.X . Assume the following mapping.

```
"country" : {
       "type" : "string",
       "analayzer" : "patternAnalyzer" //Split by commas
       "fields" : {
          "typeahead" : {
              "type" : "string"
              "analyzer" : "customAnalyzer" //Split by commas & then apply n-gram (n=3)
        }
    }
}

```

The data I would have is something like below:

```
{
     "country" : "United States of America , Canada"
}

```

The problem I have is when I try to find a matching ngram when the user types 'states'. I only expect to get 'United States of America' in my suggestions and not 'Canada'. Now I get both in autocomplete suggestions. (since the ngrams of USA and Canada are stored together).  
Is there a way to accomplish this?

Maybe someway by which the ngrams still somehow know which string they are n-grams of. (Currently I have to do a explicit pattern match on results to make sure to remove non matching ones)

Thanks in advance!

---

<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:** [April 4, 2018, 4:14pm UTC](https://discuss.elastic.co/t/problem-with-arrays-in-elastic-search/122920/2 "2018-04-04T16:14:41Z")

</div>

Closed on April 4, 2018, 4:14pm UTC

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