# Completion analyzer

**URL:** <https://discuss.elastic.co/t/completion-analyzer/109689>\
**Category:** Elasticsearch\
**Created:** [November 30, 2017, 6:13am UTC](https://discuss.elastic.co/t/completion-analyzer/109689 "2017-11-30T06:13:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shekhar\_Pandey](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shekhar\_Pandey](https://discuss.elastic.co/u/Shekhar_Pandey)\
**Post date:** [November 30, 2017, 6:13am UTC](https://discuss.elastic.co/t/completion-analyzer/109689/1 "2017-11-30T06:13:38Z")

</div>

My completion analyzer not working...mapping is like this...  
PUT music  
{  
"settings":{  
"analysis":{  
"analyzer":{  
"completion\_analyzer": {  
"tokenizer": "my\_tokenizer"

```
        }
        },
    "tokenizer": {
    "my_tokenizer": {
      "type": "keyword",
      "min_gram": 1,
      "max_gram": 20,
      "token_chars": [
        "letter",
        "digit"
      ]
    }
  }
  }

```

},  
"mappings":{  
"song":{  
"properties":{  
"suggest" : {  
"type" : "completion",  
"analyzer": "completion\_analyzer"  
}

```
     }
  }

```

}  
}

After that I index one doc like this..  
PUT music/song/1?refresh  
{  
"suggest" : {  
"input": [ "sony",  
"xperia",  
"m2",  
"3d",  
"back",  
"covers",  
"xepby",  
"xpfuson" ]

```
}

```

}

Then I did one query...  
POST music/\_search?pretty  
{  
"suggest": {  
"song-suggest" : {  
"prefix" : "x",  
"completion" : {  
"field" : "suggest",  
"size" : 5  
}  
}  
}  
}

So there is three words of x name...but result showing only one...even I applied ngram analyzer..its not working...

Result..  
{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"skipped": 0,  
"failed": 0  
},  
"hits": {  
"total": 0,  
"max\_score": 0,  
"hits": []  
},  
"suggest": {  
"song-suggest": [  
{  
"text": "x",  
"offset": 0,  
"length": 1,  
"options": [  
{  
"text": "xepby",  
"\_index": "music",  
"\_type": "song",  
"\_id": "1",  
"\_score": 1,  
"\_source": {  
"suggest": {  
"input": [  
"sony",  
"xperia",  
"m2",  
"3d",  
"back",  
"covers",  
"xepby",  
"xpfuson"  
]  
}  
}  
}  
]  
}  
]  
}  
}

Why I am not getting other x also as a suggestion...

Thanks

---

<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 1, 2017, 8:31am UTC](https://discuss.elastic.co/t/completion-analyzer/109689/2 "2017-12-01T08:31:17Z")

</div>

as all the suggestions are in one document, only this document is being returned, with one suggestions. You could control which one is returned by configured a weight.

---

<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:** [December 29, 2017, 8:31am UTC](https://discuss.elastic.co/t/completion-analyzer/109689/3 "2017-12-29T08:31:47Z")

</div>

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