# Suggest API - Can't search numbers

**URL:** <https://discuss.elastic.co/t/suggest-api-cant-search-numbers/15471>\
**Category:** Elasticsearch\
**Created:** [January 29, 2014, 11:30am UTC](https://discuss.elastic.co/t/suggest-api-cant-search-numbers/15471 "2014-01-29T11:30:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Wallett](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael\_Wallett](https://discuss.elastic.co/u/Michael_Wallett)\
**Post date:** [January 29, 2014, 11:30am UTC](https://discuss.elastic.co/t/suggest-api-cant-search-numbers/15471/1 "2014-01-29T11:30:48Z")

</div>

Hi,

I'm using the Suggest API to create an autocomplete for restaurant names,  
but I've run into a small problem. Some restaurant names start with  
numbers, for example:

68 - 86 Bar & Restaurant

I want to be able to type 68 and get the restaurant back. I've tried using  
the whitespace analyzer, but it doesn't fix my issue.

Here is the analyze output for the restaurant name:

{"tokens":[{"token":"68","start\_offset":0,"end\_offset":2,"type":"","position":1},{"token":"86","start\_offset":5,"end\_offset":7,"type":"","position":2},{"token":"bar","start\_offset":8,"end\_offset":11,"type":"","position":3},{"token":"restaurant","start\_offset":14,"end\_offset":24,"type":"","position":4}]}

Here are the commands to reproduce my issue:

PUT restaurants  
{ }

PUT restaurants/restaurant/\_mapping  
{  
"location": {  
"index\_analyzer": "whitespace",  
"search\_analyzer": "whitespace",  
"properties": {  
"name\_suggest": {  
"type": "completion",  
"payloads": true  
}  
}  
}  
}

POST restaurants/restaurant/1  
{  
"name\_suggest": {  
"input": [  
"68 - 86 Bar & Restaurant"  
],  
"output": "68 - 86 Bar & Restaurant",  
"payload": {  
"id": 1067  
}  
}  
}

POST restaurants/\_suggest  
{  
"suggestions": {  
"text": "68 - 86",  
"completion": {  
"field": "name\_suggest"  
}  
}  
}

I don't get any results from \_suggest. Any help would be appreciated.

--  
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/c983f81a-7463-453d-8389-f5c78c2e9760%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c983f81a-7463-453d-8389-f5c78c2e9760%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Michael\_Wallett](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael\_Wallett](https://discuss.elastic.co/u/Michael_Wallett)\
**Post date:** [January 29, 2014, 1:02pm UTC](https://discuss.elastic.co/t/suggest-api-cant-search-numbers/15471/2 "2014-01-29T13:02:12Z")

</div>

I've solved it, simple really, but maybe a bug?

Instead of:

PUT restaurants/restaurant/\_mapping  
{  
"location": {  
"index\_analyzer": "whitespace",  
"search\_analyzer": "whitespace",  
"properties": {  
"name\_suggest": {  
"type": "completion",  
"payloads": true  
}  
}  
}  
}

I now have:

PUT restaurants/restaurant/\_mapping  
{  
"location": {  
"properties": {  
"name\_suggest": {  
"type": "completion",  
"index\_analyzer": "whitespace",  
"search\_analyzer": "whitespace",  
"payloads": true  
}  
}  
}  
}

On Wednesday, January 29, 2014 11:30:48 AM UTC, Michael Wallett wrote:

> Hi,
> 
> I'm using the Suggest API to create an autocomplete for restaurant names,  
> but I've run into a small problem. Some restaurant names start with  
> numbers, for example:
> 
> 68 - 86 Bar & Restaurant
> 
> I want to be able to type 68 and get the restaurant back. I've tried using  
> the whitespace analyzer, but it doesn't fix my issue.
> 
> Here is the analyze output for the restaurant name:
> 
> {"tokens":[{"token":"68","start\_offset":0,"end\_offset":2,"type":"","position":1},{"token":"86","start\_offset":5,"end\_offset":7,"type":"","position":2},{"token":"bar","start\_offset":8,"end\_offset":11,"type":"","position":3},{"token":"restaurant","start\_offset":14,"end\_offset":24,"type":"","position":4}]}
> 
> Here are the commands to reproduce my issue:
> 
> PUT restaurants  
> { }
> 
> PUT restaurants/restaurant/\_mapping  
> {  
> "location": {  
> "index\_analyzer": "whitespace",  
> "search\_analyzer": "whitespace",  
> "properties": {  
> "name\_suggest": {  
> "type": "completion",  
> "payloads": true  
> }  
> }  
> }  
> }
> 
> POST restaurants/restaurant/1  
> {  
> "name\_suggest": {  
> "input": [  
> "68 - 86 Bar & Restaurant"  
> ],  
> "output": "68 - 86 Bar & Restaurant",  
> "payload": {  
> "id": 1067  
> }  
> }  
> }
> 
> POST restaurants/\_suggest  
> {  
> "suggestions": {  
> "text": "68 - 86",  
> "completion": {  
> "field": "name\_suggest"  
> }  
> }  
> }
> 
> I don't get any results from \_suggest. Any help would be appreciated.

--  
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/82861b74-f888-4389-9a69-8801cb8d9400%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/82861b74-f888-4389-9a69-8801cb8d9400%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:54am UTC](https://discuss.elastic.co/t/suggest-api-cant-search-numbers/15471/3 "2017-07-06T01:54:13Z")

</div>


