# Autocomplete in elasticsearch

**URL:** <https://discuss.elastic.co/t/autocomplete-in-elasticsearch/88549>\
**Category:** Elasticsearch\
**Created:** [June 7, 2017, 9:46am UTC](https://discuss.elastic.co/t/autocomplete-in-elasticsearch/88549 "2017-06-07T09:46:24Z")\
**Posts on this page:** 4\
**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 7, 2017, 9:46am UTC](https://discuss.elastic.co/t/autocomplete-in-elasticsearch/88549/1 "2017-06-07T09:46:24Z")

</div>

currently, I'm building autocomplete. here my Elasticsearch query.

> ```
> PUT test_index
> {
> "settings": {
> "index": {
> "analysis": {
> "filter": {
> "stemmer": {
> "type": "stemmer",
> "language": "english"
> },
>     
> "stopwords": {
> "type": "stop",
> "stopwords": [
> "_english_"
> ]
> }
> },
> "analyzer": {
> "autocomplete": {
> "filter": [
> ["lowercase", "asciifolding"]
> ],
> "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"
> ]
> }
> }
> }
> }
> }
> 
> ```

```
  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/6
{
  "title": "Apploo i Phone 4S",
  "description": "some description"
}

```

#autocomplete  
POST /test\_index/\_search/  
{  
"aggs": {  
"autocomplete": {  
"terms": {  
"field": "autocomplete",  
"order": {  
"\_count": "desc"  
},  
"include": "APP._"  
}  
}  
},  
"query": {  
"query\_string": {  
"query": "APP_",  
"fields": [  
"autocomplete"  
]  
}  
}  
}

This is not supported in case-sensitive, and whitespace search (I phone). If I search "I phone" or "APPLE" there is no aggregation result.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [June 7, 2017, 10:31am UTC](https://discuss.elastic.co/t/autocomplete-in-elasticsearch/88549/2 "2017-06-07T10:31:10Z")

</div>

> [@arafath](#):
>
> currently, I'm building autocomplete

Have you looked at[completion suggester](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html)?

---

<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 7, 2017, 11:34am UTC](https://discuss.elastic.co/t/autocomplete-in-elasticsearch/88549/3 "2017-06-07T11:34:07Z")

</div>

Yes. I tried with completion suggester. I want like [https://www.gumtree.com](https://www.gumtree.com) search

---

<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 5, 2017, 11:34am UTC](https://discuss.elastic.co/t/autocomplete-in-elasticsearch/88549/4 "2017-07-05T11:34:39Z")

</div>

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