# Completion suggester not working as expected for field with array of strings

**URL:** <https://discuss.elastic.co/t/completion-suggester-not-working-as-expected-for-field-with-array-of-strings/246676>\
**Category:** Elasticsearch\
**Created:** [August 27, 2020, 6:29pm UTC](https://discuss.elastic.co/t/completion-suggester-not-working-as-expected-for-field-with-array-of-strings/246676 "2020-08-27T18:29:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivasan\_Ramaswamy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivasan_ramaswamy/32/74106_2.png) [@Srinivasan\_Ramaswamy](https://discuss.elastic.co/u/Srinivasan_Ramaswamy)\
**Post date:** [August 27, 2020, 6:29pm UTC](https://discuss.elastic.co/t/completion-suggester-not-working-as-expected-for-field-with-array-of-strings/246676/1 "2020-08-27T18:29:29Z")

</div>

Here is the mapping and how i index the documents

```
    PUT http://localhost:9200/tag_completion/
    {
    "mappings": {
        "properties": {
          "title": { "type": "text" },
          "tags": { "type": "completion"}
        }
      }
    }

    POST http://localhost:9200/tag_completion/_doc/1
    {
        "title": "brown bear",
        "tags": ["colorful", "children", "crayons", "toddler"]
    }

    POST http://localhost:9200/tag_completion/_doc/2
    {
        "title": "hungry caterpillar",
        "tags": ["colorful", "science", "toddler"]
    }

    POST http://localhost:9200/tag_completion/_doc/3
    {
        "title": "harry potter",
        "tags": ["fiction", "magic", "wizard", "fantasy"]
    } 

```

Here is the search query i use for autocomplete

```
POST http://localhost:9200/tag_completion/_search
{
  "suggest": {
    "tags-suggest": {
      "prefix": "c",
      "completion": {
        "field": "tags",
        "skip_duplicates": true
      }
    }
  }
}

```

expected suggestions = ["colorful","children","crayons"]  
actual suggestions = ["children"]

Observations:

1. looks like "colorful" got filtered due to skip\_duplicates, though it is available in two different documents
2. only one match is picked from a document, when the prefix matches multiple strings in a document

Can someone share some pointers on how the array of strings are stored in the FST. Is this a bug or am i missing something ?

Thanks  
Srini

---

<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:** [September 24, 2020, 6:29pm UTC](https://discuss.elastic.co/t/completion-suggester-not-working-as-expected-for-field-with-array-of-strings/246676/2 "2020-09-24T18:29:41Z")

</div>

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