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

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

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