# Suggest feature not returning options

**URL:** <https://discuss.elastic.co/t/suggest-feature-not-returning-options/12775>\
**Category:** Elasticsearch\
**Created:** [July 12, 2013, 6:00pm UTC](https://discuss.elastic.co/t/suggest-feature-not-returning-options/12775 "2013-07-12T18:00:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Walters](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scott_walters/32/2220_2.png) [@Scott\_Walters](https://discuss.elastic.co/u/Scott_Walters)\
**Post date:** [July 12, 2013, 6:00pm UTC](https://discuss.elastic.co/t/suggest-feature-not-returning-options/12775/1 "2013-07-12T18:00:20Z")

</div>

Hi,

I have a working elastic search installation and I'm trying to get the  
suggestions feature working but it never returns any options.

I've stripped down my issue to the bare essentials.  
The mapping looks like this...

curl -XPUT localhost:9200/card-search-model-v18 -d '  
{  
"mappings":{

```
    "properties": {
        "doc": {
            "dynamic": "true",
            "properties": {
                "title": {
                    "type": "string"
                }
            }
        }
    }
}

```

}'

My indexed documents have a title property. Several of them have a title  
containing the string "references". I can issue a search and get correct  
results by executing...

curl -s -XPOST 'localhost:9200/card-search-model-v18/\_search' -d '{  
"query": {  
"bool": {  
"should": [  
{  
"wildcard": {  
"title": "_refer_"  
}  
}  
]  
}  
}  
}'

When I try a suggest query, the options array is always empty. Here's one  
with the mis-typed string "refe[f]ences"

curl -XPOST 'localhost:9200/card-search-model-v18/\_suggest' -d '{  
"mysuggest" : {  
"text" : "refefences",  
"term" : {  
"field" : "title"  
}  
}  
}'

Is there something else I need to setup? Is there something wrong with the  
suggest query?

Thanks,  
Scott

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 15, 2013, 6:43am UTC](https://discuss.elastic.co/t/suggest-feature-not-returning-options/12775/2 "2013-07-15T06:43:59Z")

</div>

Hey,

strange, can you post some of your data you indexed and your mapping of  
that index, seems to work here after a quick test

curl -X DELETE localhost:9200/test  
curl -X PUT localhost:9200/test  
curl -X PUT 'localhost:9200/test/foo/1?refresh=true' -d '{ "title": "My  
references" }'  
curl -X PUT 'localhost:9200/test/foo/2?refresh=true' -d '{ "title": "Your  
references" }'  
curl -X PUT 'localhost:9200/test/foo/3?refresh=true' -d '{ "title": "Our  
references" }'  
curl -XPOST 'localhost:9200/test/\_suggest' -d '{ "test" : { "text" :  
"refefences", "term" : { "field" : "title" } } }'

what's the difference between your and my sample?

--Alex

On Fri, Jul 12, 2013 at 8:00 PM, Scott Walters [scottw512@gmail.com](mailto:scottw512@gmail.com) wrote:

> Hi,
> 
> I have a working Elasticsearch installation and I'm trying to get the  
> suggestions feature working but it never returns any options.
> 
> I've stripped down my issue to the bare essentials.  
> The mapping looks like this...
> 
> curl -XPUT localhost:9200/card-search-model-v18 -d '  
> {  
> "mappings":{
> 
> ```
> "properties": {
> "doc": {
> "dynamic": "true",
> "properties": {
> "title": {
> "type": "string"
> }
> }
> }
> }
> }
> 
> ```
> 
> }'
> 
> My indexed documents have a title property. Several of them have a title  
> containing the string "references". I can issue a search and get correct  
> results by executing...
> 
> curl -s -XPOST 'localhost:9200/card-search-model-v18/\_search' -d '{  
> "query": {  
> "bool": {  
> "should": [  
> {  
> "wildcard": {  
> "title": "_refer_"  
> }  
> }  
> ]  
> }  
> }  
> }'
> 
> When I try a suggest query, the options array is always empty. Here's one  
> with the mis-typed string "refe[f]ences"
> 
> curl -XPOST 'localhost:9200/card-search-model-v18/\_suggest' -d '{  
> "mysuggest" : {  
> "text" : "refefences",  
> "term" : {  
> "field" : "title"  
> }  
> }  
> }'
> 
> Is there something else I need to setup? Is there something wrong with the  
> suggest query?
> 
> Thanks,  
> Scott
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Scott\_Walters](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scott_walters/32/2220_2.png) [@Scott\_Walters](https://discuss.elastic.co/u/Scott_Walters)\
**Post date:** [July 16, 2013, 3:46pm UTC](https://discuss.elastic.co/t/suggest-feature-not-returning-options/12775/3 "2013-07-16T15:46:49Z")

</div>

Thanks for the reply. I tried your sample and it works for me. Now I'm  
trying to figure out why. I think it has something to do with my mapping  
(which is below) not agreeing with the input JSON to the suggest API. As an  
experiment, I tried using the POST and suggest commands from your example  
against my index. When I did this, I got results. The commands I tried were

curl -X PUT 'localhost:9200/card-search-model-v18/foo/3333?refresh=true' -d  
'{ "title": "Our references" }'  
curl -XPOST 'localhost:9200/card-search-model-v18/\_suggest' -d '{ "test" :  
{ "text" : "refefences", "term" : { "field" : "title" } } }'

So now I'm pondering the significance of the "foo" part of the URL in your  
example, and why it would search documents from there and now where the  
couchbase transport plugin is putting them

The mapping I tried was

curl -XPUT localhost:9200/cst1 -d '  
{  
"mappings":{  
"couchbaseDocument": {  
"properties": {  
"doc": {  
"dynamic": "true",  
"properties": {  
"title": {  
"type": "string"  
}  
}  
}  
}  
}  
}  
}'

On Monday, July 15, 2013 1:43:59 AM UTC-5, Alexander Reelsen wrote:

> Hey,
> 
> strange, can you post some of your data you indexed and your mapping of  
> that index, seems to work here after a quick test
> 
> curl -X DELETE localhost:9200/test  
> curl -X PUT localhost:9200/test  
> curl -X PUT 'localhost:9200/test/foo/1?refresh=true' -d '{ "title": "My  
> references" }'  
> curl -X PUT 'localhost:9200/test/foo/2?refresh=true' -d '{ "title": "Your  
> references" }'  
> curl -X PUT 'localhost:9200/test/foo/3?refresh=true' -d '{ "title": "Our  
> references" }'  
> curl -XPOST 'localhost:9200/test/\_suggest' -d '{ "test" : { "text" :  
> "refefences", "term" : { "field" : "title" } } }'
> 
> what's the difference between your and my sample?
> 
> --Alex
> 
> On Fri, Jul 12, 2013 at 8:00 PM, Scott Walters \<[scot...@gmail.com](mailto:scot...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi,
> > 
> > I have a working Elasticsearch installation and I'm trying to get the  
> > suggestions feature working but it never returns any options.
> > 
> > I've stripped down my issue to the bare essentials.  
> > The mapping looks like this...
> > 
> > curl -XPUT localhost:9200/card-search-model-v18 -d '  
> > {  
> > "mappings":{
> > 
> > ```
> > "properties": {
> > "doc": {
> > "dynamic": "true",
> > "properties": {
> > "title": {
> > "type": "string"
> > }
> > }
> > }
> > }
> > }
> > 
> > ```
> > 
> > }'
> > 
> > My indexed documents have a title property. Several of them have a title  
> > containing the string "references". I can issue a search and get correct  
> > results by executing...
> > 
> > curl -s -XPOST 'localhost:9200/card-search-model-v18/\_search' -d '{  
> > "query": {  
> > "bool": {  
> > "should": [  
> > {  
> > "wildcard": {  
> > "title": "_refer_"  
> > }  
> > }  
> > ]  
> > }  
> > }  
> > }'
> > 
> > When I try a suggest query, the options array is always empty. Here's one  
> > with the mis-typed string "refe[f]ences"
> > 
> > curl -XPOST 'localhost:9200/card-search-model-v18/\_suggest' -d '{  
> > "mysuggest" : {  
> > "text" : "refefences",  
> > "term" : {  
> > "field" : "title"  
> > }  
> > }  
> > }'
> > 
> > Is there something else I need to setup? Is there something wrong with  
> > the suggest query?
> > 
> > Thanks,  
> > Scott
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Scott\_Walters](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scott_walters/32/2220_2.png) [@Scott\_Walters](https://discuss.elastic.co/u/Scott_Walters)\
**Post date:** [July 16, 2013, 5:44pm UTC](https://discuss.elastic.co/t/suggest-feature-not-returning-options/12775/4 "2013-07-16T17:44:51Z")

</div>

Hi,

I have found out what the problem is. Going back to the model and queries  
in the original post, and looking at the documents I was searching on, I  
noticed there was an extra JSON node called doc, so I modified the suggest  
query to look like the one below, where I highlighted the modified field  
term. Now I get the suggestions I was expecting.

curl -XPOST 'localhost:9200/card-search-model-v18/\_suggest' -d '{  
"mysuggest" : {  
"text" : "refefences",  
"term" : {  
"field" : "doc.title"  
}  
}  
}'

On Tuesday, July 16, 2013 10:46:49 AM UTC-5, Scott Walters wrote:

> Thanks for the reply. I tried your sample and it works for me. Now I'm  
> trying to figure out why. I think it has something to do with my mapping  
> (which is below) not agreeing with the input JSON to the suggest API. As an  
> experiment, I tried using the POST and suggest commands from your example  
> against my index. When I did this, I got results. The commands I tried were
> 
> curl -X PUT 'localhost:9200/card-search-model-v18/foo/3333?refresh=true'  
> -d '{ "title": "Our references" }'  
> curl -XPOST 'localhost:9200/card-search-model-v18/\_suggest' -d '{ "test" :  
> { "text" : "refefences", "term" : { "field" : "title" } } }'
> 
> So now I'm pondering the significance of the "foo" part of the URL in your  
> example, and why it would search documents from there and now where the  
> couchbase transport plugin is putting them
> 
> The mapping I tried was
> 
> curl -XPUT localhost:9200/cst1 -d '  
> {  
> "mappings":{  
> "couchbaseDocument": {  
> "properties": {  
> "doc": {  
> "dynamic": "true",  
> "properties": {  
> "title": {  
> "type": "string"  
> }  
> }  
> }  
> }  
> }  
> }  
> }'
> 
> On Monday, July 15, 2013 1:43:59 AM UTC-5, Alexander Reelsen wrote:
> 
> > Hey,
> > 
> > strange, can you post some of your data you indexed and your mapping of  
> > that index, seems to work here after a quick test
> > 
> > curl -X DELETE localhost:9200/test  
> > curl -X PUT localhost:9200/test  
> > curl -X PUT 'localhost:9200/test/foo/1?refresh=true' -d '{ "title": "My  
> > references" }'  
> > curl -X PUT 'localhost:9200/test/foo/2?refresh=true' -d '{ "title": "Your  
> > references" }'  
> > curl -X PUT 'localhost:9200/test/foo/3?refresh=true' -d '{ "title": "Our  
> > references" }'  
> > curl -XPOST 'localhost:9200/test/\_suggest' -d '{ "test" : { "text" :  
> > "refefences", "term" : { "field" : "title" } } }'
> > 
> > what's the difference between your and my sample?
> > 
> > --Alex
> > 
> > On Fri, Jul 12, 2013 at 8:00 PM, Scott Walters [scot...@gmail.com](mailto:scot...@gmail.com) wrote:
> > 
> > > Hi,
> > > 
> > > I have a working Elasticsearch installation and I'm trying to get the  
> > > suggestions feature working but it never returns any options.
> > > 
> > > I've stripped down my issue to the bare essentials.  
> > > The mapping looks like this...
> > > 
> > > curl -XPUT localhost:9200/card-search-model-v18 -d '  
> > > {  
> > > "mappings":{
> > > 
> > > ```
> > > "properties": {
> > > "doc": {
> > > "dynamic": "true",
> > > "properties": {
> > > "title": {
> > > "type": "string"
> > > }
> > > }
> > > }
> > > }
> > > }
> > > 
> > > ```
> > > 
> > > }'
> > > 
> > > My indexed documents have a title property. Several of them have a title  
> > > containing the string "references". I can issue a search and get correct  
> > > results by executing...
> > > 
> > > curl -s -XPOST 'localhost:9200/card-search-model-v18/\_search' -d '{  
> > > "query": {  
> > > "bool": {  
> > > "should": [  
> > > {  
> > > "wildcard": {  
> > > "title": "_refer_"  
> > > }  
> > > }  
> > > ]  
> > > }  
> > > }  
> > > }'
> > > 
> > > When I try a suggest query, the options array is always empty. Here's  
> > > one with the mis-typed string "refe[f]ences"
> > > 
> > > curl -XPOST 'localhost:9200/card-search-model-v18/\_suggest' -d '{  
> > > "mysuggest" : {  
> > > "text" : "refefences",  
> > > "term" : {  
> > > "field" : "title"  
> > > }  
> > > }  
> > > }'
> > > 
> > > Is there something else I need to setup? Is there something wrong with  
> > > the suggest query?
> > > 
> > > Thanks,  
> > > Scott
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
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, 2:26am UTC](https://discuss.elastic.co/t/suggest-feature-not-returning-options/12775/5 "2017-07-06T02:26:08Z")

</div>


