# ElasticSearch Autocomplete Feature

**URL:** <https://discuss.elastic.co/t/elasticsearch-autocomplete-feature/21846>\
**Category:** Elasticsearch\
**Created:** [January 27, 2015, 10:18am UTC](https://discuss.elastic.co/t/elasticsearch-autocomplete-feature/21846 "2015-01-27T10:18:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CY\_Kuek](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@CY\_Kuek](https://discuss.elastic.co/u/CY_Kuek)\
**Post date:** [January 27, 2015, 10:18am UTC](https://discuss.elastic.co/t/elasticsearch-autocomplete-feature/21846/1 "2015-01-27T10:18:09Z")

</div>

Hi All,

I am new to ElasticSearch and currently I am using ElasticSearch to connect  
to MongoDB for indexing and searching. I would like to implement keyword  
auto-complete feature like search engines which provide a list of  
suggestion keyword when user key in partial keywords. I had a document  
which contains many fields and I only want the auto-complete keyword to  
search on 4 fields (title, description, category and sub-category) . Below  
is the index that I am creating:

_curl -XPUT [http://localhost:9200/testindex](http://localhost:9200/testindex) -d '_  
_{_

- "settings": {\*
- 

```
 "analysis":{*

```

- 

```
     "filter":{*

```

- 

```
         "edge_nGram_filter":{*

```

- 

```
             "type":"edgeNGram",*

```

- 

```
             "min_gram": 1,*

```

- 

```
             "max_gram": 50,*

```

- 

```
             "token_chars": [*

```

- 

```
                 "letter",*

```

- 

```
                 "digit",*

```

- 

```
                 "punctuation",*

```

- 

```
                 "symbol"*

```

- 

```
             ]*

```

- 

```
         }*

```

- 

```
     },*

```

- 

```
     "analyzer": {*

```

- 

```
         "edge_nGram_analyzer": {*

```

- 

```
              "type": "custom",*

```

- 

```
              "tokenizer": "whitespace",*

```

- 

```
              "filter": [*

```

- 

```
                  "lowercase",*

```

- 

```
                  "asciifolding",*

```

- 

```
                  "edge_nGram_filter"*

```

- 

```
              ]*

```

- 

```
         },*

```

- 

```
         "whitespace_analyzer": {*

```

- 

```
             "type": "custom",*

```

- 

```
             "tokenizer": "whitespace",*

```

- 

```
             "filter": [*

```

- 

```
                 "lowercase",*

```

- 

```
                 "asciifolding"*

```

- 

```
             ]*

```

- 

```
         }*

```

- 

```
    }*

```

- 

```
 }*

```

- },\*
- "mappings" : {\*
- 

```
 "Merchant" : {*

```

- 

```
     "_all": {*

```

- 

```
       "index_analyzer": "edge_nGram_analyzer",*

```

- 

```
       "search_analyzer": "whitespace_analyzer"*

```

- 

```
     },*

```

- 

```
     "properties" : {*

```

- 

```
         "screenNm": {*

```

- 

```
             "type": "string",*

```

- 

```
             "index": "no",*

```

- 

```
             "include_in_all": false*

```

- 

```
         },*

```

- 

```
         "categoryId": {*

```

- 

```
                     "type": "long", *

```

- 

```
                     "index": "no",*

```

- 

```
                     "include_in_all": false*

```

- 

```
         },*

```

- 

```
         "title": {*

```

- 

```
             "type": "string",*

```

- 

```
             "index": "not_analyzed"*

```

- 

```
         },*

```

- 

```
         "desc": {*

```

- 

```
             "type": "string",*

```

- 

```
             "index": "not_analyzed"*

```

- 

```
         },*

```

- 

```
        "email": { "type": "string",                

```

"index": "no", "include\_in\_all": false },  
"createdAt": { "format": "dateOptionalTime",  
"type": "date", "index": "no",  
"include\_in\_all": false },  
"subCategoryList": {\*
- 

```
             "properties" : {*

```

- 

```
                 "subCategoryId": {*

```

- 

```
                     "type": "long", *

```

- 

```
                     "index": "no",*

```

- 

```
                     "include_in_all": false*

```

- 

```
                 },*

```

- 

```
                 "subCategory": {*

```

- 

```
                     "type": "string",*

```

- 

```
                     "index": "not_analyzed"*

```

- 

```
                 }*

```

- 

```
             }*

```

- 

```
         },*

```

- 

```
         "category": {*

```

- 

```
             "type": "string",*

```

- 

```
             "index": "not_analyzed"*

```

- 

```
         }*

```

- 

```
     }*

```

- 

```
 }*

```

- }\*  
_}'_

Below is my questions and I am hoping some of you could shed me some lights:

1. When I perform match query search on "_\_al_l" fields for keyword "_food_"  
(I had set the returned record size to 6), I will get 6 documents which  
match the \*food \*keyword in either of the fields (title, description,  
category and sub-category). Result example as the following:

2. Can we perform my scenario using completion suggester?? As I need to  
perform search on multiple fields.

3. Is performance a issue if I am using edgeNGram on large documents set?

Appreciate your help. Thanks a lot !!!

Regards,  
CYea

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/3b2bd828-02c4-4899-a615-2a773b6d671a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3b2bd828-02c4-4899-a615-2a773b6d671a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:36am UTC](https://discuss.elastic.co/t/elasticsearch-autocomplete-feature/21846/2 "2017-07-06T00:36:29Z")

</div>


