# Autosuggest more then one word?

**URL:** <https://discuss.elastic.co/t/autosuggest-more-then-one-word/6746>\
**Category:** Elasticsearch\
**Created:** [February 19, 2012, 1:43am UTC](https://discuss.elastic.co/t/autosuggest-more-then-one-word/6746 "2012-02-19T01:43:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![roger\_2](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@roger\_2](https://discuss.elastic.co/u/roger_2)\
**Post date:** [February 19, 2012, 1:43am UTC](https://discuss.elastic.co/t/autosuggest-more-then-one-word/6746/1 "2012-02-19T01:43:41Z")

</div>

Hi elasticsearchers

I'm trying to find a way to implement an auto suggest/complete search.

As far as I can see there is no way to search for more then one word  
in an auto suggest string e.g. "Steve Boston" using nGram and  
phrase\_prefix.

Our elasticsearch.json looks like:

"index": {  
"analysis" : {  
"default": "textAnalyzer",  
"analyzer": {  
"nGramAnalyzer" : {  
"type": "custom",  
"tokenizer": "standard",  
"filter" : ["standard", "lowercase", "nGramFilter"]  
}  
},  
"filter" : {  
"nGramFilter" : {  
"type" : "nGram",  
"min\_gram" : 2,  
"max\_gram" : 25  
}  
}  
}  
}

Our index mapping looks like:

"userName": {  
"type": "string",  
"index": "analyzed",  
"index\_analyzer": "nGramAnalyzer",  
"search\_analyzer": "default",  
"include\_in\_all": false,  
"null\_value": "na",  
"boost": 2.0

}

And the indexed userName value is:  
"Steve Miller, Boston"

The following query will work as excepted.

Split the query string "Steve Boston" or "Steve Bost" into a  
bool:must:text query using phrase\_prefix for each word from  
the search string:

{  
"query": {  
"bool": {  
"must": [  
{  
"text": {  
"userName": {  
"analyzer": "default",  
"type": "phrase\_prefix",  
"query": "Steve"  
}  
}  
},  
{  
"text": {  
"userName": {  
"analyzer": "default",  
"type": "phrase\_prefix",  
"query": "Boston"  
}  
}  
}  
]  
}  
}  
}

Is this the recommended concept for query more then one word?  
Or is there a better/faster concept?

Regards  
Roger Ineichen

* * *

END OF MESSAGE

---

<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, 3:38am UTC](https://discuss.elastic.co/t/autosuggest-more-then-one-word/6746/2 "2017-07-06T03:38:51Z")

</div>


