# Auto Suggestion in Elasticsearch

**URL:** <https://discuss.elastic.co/t/auto-suggestion-in-elasticsearch/88652>\
**Category:** Elasticsearch\
**Created:** [June 8, 2017, 5:23am UTC](https://discuss.elastic.co/t/auto-suggestion-in-elasticsearch/88652 "2017-06-08T05:23:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arafath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arafath/32/12784_2.png) [@arafath](https://discuss.elastic.co/u/arafath)\
**Post date:** [June 8, 2017, 5:23am UTC](https://discuss.elastic.co/t/auto-suggestion-in-elasticsearch/88652/1 "2017-06-08T05:23:31Z")

</div>

I have implemented onlt one word combine auto suggestion in ES. But i couldn't implement three word combine auto search as I mention below screenshot.

 ![](https://us1.discourse-cdn.com/elastic/original/3X/3/1/31d8ec47b0232cf49fac0de85415eb0bef27f7b0.png)

ES record output

> ```
> {
> "took": 7,
> "timed_out": false,
> "_shards": {
> "total": 5,
> "successful": 5,
> "failed": 0
> },
> "hits": {
> "total": 4,
> "max_score": 1,
> "hits": [
> {
> "_index": "test_index",
> "_type": "test_type",
> "_id": "4",
> "_score": 1,
> "_source": {
> "title": "Apple i Phone 4S",
> "description": "some description"
> }
> },
> {
> "_index": "test_index",
> "_type": "test_type",
> "_id": "2",
> "_score": 1,
> "_source": {
> "title": "Apple iPhone I Phone 5 Original",
> "description": "some description"
> }
> },
> {
> "_index": "test_index",
> "_type": "test_type",
> "_id": "1",
> "_score": 1,
> "_source": {
> "title": "Apple iPhone 6+",
> "description": "some description"
> }
> },
> {
> "_index": "test_index",
> "_type": "test_type",
> "_id": "3",
> "_score": 1,
> "_source": {
> "title": "Apple iMac 21.5/2.8GHz/i5/8GB 2016",
> "description": "some description"
> }
> }
> ]
> },
> "aggregations": {
> "autocomplete": {
> "doc_count_error_upper_bound": 0,
> "sum_other_doc_count": 0,
> "buckets": [
> {
> "key": "apple",
> "doc_count": 4
> }
> ]
> }
> }
> }
> 
> ```

here my ES query.  
PUT test\_index

> ```
> {
> "settings": {
> "index": {
> "analysis": {
> "filter": {
> "stemmer": {
> "type": "stemmer",
> "language": "english"
> },
>     
> "stopwords": {
> "type": "stop",
> "stopwords": [
> "_english_"
> ]
> }
> },
> "analyzer": {
> "autocomplete": {
> "filter": [
> "lowercase"
> ],
> "char_filter": [
> "html_strip"
> ],
> "type": "custom",
> "tokenizer": "standard"
> },
> "default": {
> "filter": [
> "lowercase",
> "stopwords",
> "stemmer"
> ],
> "char_filter": [
> "html_strip"
> ],
> "type": "custom",
> "tokenizer": "standard"
> }
> }
> }
> }
> },
> "mappings": {
> "test_type": {
> "properties": {
> "autocomplete": {
> "type": "text",
> "analyzer": "autocomplete",
> "fielddata": true
> },
> "description": {
> "type": "text"
> },
> "title": {
> "type": "text",
> "copy_to": [
> "autocomplete"
> ]
> }
> }
> }
> }
> }
> 
> ```

ES Document

> ```
> POST /test_index/test_type/1
> {
> "title": "Apple iPhone 6+",
> "description": "some description"
> }
> POST /test_index/test_type/2
> {
> "title": "Apple iPhone I Phone 5 Original",
> "description": "some description"
> }
> POST /test_index/test_type/3
> {
> "title": "Apple iMac 21.5/2.8GHz/i5/8GB 2016",
> "description": "some description"
> }
> POST /test_index/test_type/4
> {
> "title": "Apple i Phone 4S",
> "description": "some description"
> }
> POST /test_index/test_type/5
> {
> "title": "Amazon kindle",
> "description": "some description"
> }
> POST /test_index/test_type/7
> {
> "title": "Apploo i Phone 4S",
> "description": "some description"
> }
> 
> ```

---

<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:** [July 6, 2017, 5:23am UTC](https://discuss.elastic.co/t/auto-suggestion-in-elasticsearch/88652/2 "2017-07-06T05:23:31Z")

</div>

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