# Term suggester example?

**URL:** https://discuss.elastic.co/t/term-suggester-example/23072
**Category:** Elasticsearch
**Created:** [April 2, 2015, 7:58pm UTC](https://discuss.elastic.co/t/term-suggester-example/23072 "2015-04-02T19:58:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cching](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cching/32/44800_2.png) [@cching](https://discuss.elastic.co/u/cching)
#### Post date: [April 2, 2015, 7:58pm UTC](https://discuss.elastic.co/t/term-suggester-example/23072/1 "2015-04-02T19:58:13Z")

</div>

I am trying to get term suggest to work and it may be that it's not going  
to work the way I think it should, but I can't seem to get it to work _at  
all_. So I put together an example index to illustrate the point,  
hopefully someone can point out what I'm doing wrong.

Basically, I want to be able to get suggestions for documents based on  
terms. For instance, if I have documents with a name of "North America"  
and "South America", I would like a \_suggest of "america" to return  
suggestions for both of those documents. Note that I'm moving away from  
completion suggest because they are documented and appear to work only as  
prefix suggestors.

Here is my not-working example, appreciate any pointers!

#!/bin/sh

ES=localhost:9200

echo "\>\>\> Deleting \_all"  
curl -XDELETE $ES/\_all

CONTINENTS=("North America" "South America" "Europe" "Asia" "Australia")  
for ((i = 0; i \< ${#CONTINENTS[@]}; i++))  
do  
c=${CONTINENTS[$i]}  
echo "\>\>\> Indexing the '$c' document"  
curl -XPOST $ES/continents/continent -d'  
{  
"name": "$c"  
}  
' && echo  
echo "${CONTINENTS[$i]}"  
done

curl -XPOST $ES/continents/\_flush && echo

# Search for the document using the name

echo  
echo "\>\>\> Getting \_suggest for 'america'"  
echo  
curl $ES/continents/\_suggest -d'  
{  
"my-suggestion" : {  
"text" : "america",  
"term" : {  
"field" : "name",  
"suggest\_mode" : "always"  
}  
}  
}' && echo

Here's the output I'm currently getting:

> > > Getting \_suggest for 'america'

{"\_shards":{"total":5,"successful":5,"failed":0},"my-suggestion":[{"text":  
"america","offset":0,"length":7,"options":}]}

--  
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/56349847-7ee6-4d06-9b26-d624878a311a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/56349847-7ee6-4d06-9b26-d624878a311a%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:22am UTC](https://discuss.elastic.co/t/term-suggester-example/23072/2 "2017-07-06T00:22:00Z")

</div>


