# Phrase suggester and non-existing terms

**URL:** <https://discuss.elastic.co/t/phrase-suggester-and-non-existing-terms/14640>\
**Category:** Elasticsearch\
**Created:** [November 28, 2013, 9:31pm UTC](https://discuss.elastic.co/t/phrase-suggester-and-non-existing-terms/14640 "2013-11-28T21:31:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christoph\_Haas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christoph_haas/32/1947_2.png) [@Christoph\_Haas](https://discuss.elastic.co/u/Christoph_Haas)\
**Post date:** [November 28, 2013, 9:31pm UTC](https://discuss.elastic.co/t/phrase-suggester-and-non-existing-terms/14640/1 "2013-11-28T21:31:48Z")

</div>

Dear list,

I'm about to implement a full-text search for a web site and am a bit  
stuck on a "did you mean"-like functionality. If no results were found I  
would like to point the visitor to more promising search queries. So  
what I'm doing:

curl -s -XPOST 'torf:9200/debshots/jdbc/\_search?search\_type=count' -d '{  
"suggest" : {  
"text" : "editar zaphodbeeblebrox",  
"simple\_phrase" : {  
"phrase" : {  
"analyzer" : "simple",  
"field" : "description",  
"size" : 4,  
"real\_word\_error\_likelihood" : 0.95,  
"confidence" : 2.0,  
"gram\_size" : 1,  
"highlight": {  
"pre\_tag": "_",  
"post\_tag": "_"  
},  
"direct\_generator" : [{  
"field" : "description",  
"suggest\_mode" : "missing",  
"min\_doc\_freq" : 1,  
"min\_word\_len" : 1  
}]  
}  
}  
}  
}' | json\_pp

I would expect that I get "editor" back because "editar" was a typo and  
"zaphodbeeblebrox" does not exist anywhere in my index. But what I get  
instead is:

{  
"hits" : {  
"hits" : [],  
"max\_score" : 0,  
"total" : 43682  
},  
"timed\_out" : false,  
"suggest" : {  
"simple\_phrase" : [  
{  
"length" : 23,  
"options" : [  
{  
"text" : "editor zaphodbeeblebrox",  
"score" : 0.00022499196,  
"highlighted" : "_editor_ zaphodbeeblebrox"  
},  
{  
"text" : "edit zaphodbeeblebrox",  
"score" : 6.074264e-05,  
"highlighted" : "_edit_ zaphodbeeblebrox"  
},  
{  
"text" : "editors zaphodbeeblebrox",  
"score" : 4.8506903e-05,  
"highlighted" : "_editors_ zaphodbeeblebrox"  
}  
],  
"text" : "editar zaphodbeeblebrox",  
"offset" : 0  
}  
]  
},  
"\_shards" : {  
"failed" : 0,  
"successful" : 1,  
"total" : 1  
},  
"took" : 16  
}

The problem is that if a user would start to search for "editors  
zaphodbeeblebrox" as suggest he would find no documents.

So my question is: how can I change the search / phrase-suggest query to  
remove words that are not found anyway? I was tempted to take the  
highlighted suggestions and just keep the words between the _…_  
tags but that feels dirty and I'm sure there is a better way.

Thanks in advance for your help.

…Christoph

--  
A distributed system is one in which I cannot get something done  
because a machine I've never heard of is down. (Leslie Lamport)

--  
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/5297B644.9020203%40christoph-haas.de](https://groups.google.com/d/msgid/elasticsearch/5297B644.9020203%40christoph-haas.de).  
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:04am UTC](https://discuss.elastic.co/t/phrase-suggester-and-non-existing-terms/14640/2 "2017-07-06T02:04:16Z")

</div>


