# Better phrase suggestions for spelling mistakes

**URL:** <https://discuss.elastic.co/t/better-phrase-suggestions-for-spelling-mistakes/17657>\
**Category:** Elasticsearch\
**Created:** [May 21, 2014, 9:51pm UTC](https://discuss.elastic.co/t/better-phrase-suggestions-for-spelling-mistakes/17657 "2014-05-21T21:51:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Thathoo](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@Rahul\_Thathoo](https://discuss.elastic.co/u/Rahul_Thathoo)\
**Post date:** [May 21, 2014, 9:51pm UTC](https://discuss.elastic.co/t/better-phrase-suggestions-for-spelling-mistakes/17657/1 "2014-05-21T21:51:38Z")

</div>

Hi.

I have a small index of about 4000 documents. Each document has a field  
called suggestion\_name which is the title of the document. Here is what the  
relevant part of our mapping looks like:

MAPPING = {  
:properties =\> {  
:id =\> { :type =\> 'string' },  
:name =\> { :type =\> 'string', :analyzer =\> :snowball\_name, boost: 1.5 },  
:suggestion\_name =\> { :type =\> 'string', :index =\> 'not\_analyzed' },

I want to be able to provide our users a really solid "Did you mean"  
feature. I am using these phrase suggestion settings currently:

def self.suggest\_phrase(query\_string)  
self.suggest( :index =\> "special\_topics", :body =\> {  
:text =\> query\_string,  
:simple\_phrase =\> {  
:phrase =\> {  
:field =\> "suggestion\_name",  
:size =\> 1,  
:real\_word\_error\_likelihood =\> 0.95,  
:max\_errors =\> 50,  
:gram\_size =\> 2,  
:direct\_generator =\> [{  
:field =\> "suggestion\_name",  
:suggest\_mode =\> "always",  
:min\_word\_length =\> 1  
}]  
}  
}  
})  
end

But this is less than ideal. For example, a document has the title "Sports  
Massage Extreme". Mis-spelling like this work : "sports massag extreme" & "  
sprts massag extreme". But the moment I try something like this: "sprts  
massag extreeme" it fails. I have tried many, many ways to tweak the  
various knobs for the phrase suggestion but nothing seems to do the trick.  
I have tried removing the "gram\_size" param completely, adjusting the  
"max\_errors" params, etc. I have tried tweaking the direct\_generator  
various ways like increasing the "size" to 10. Nothing! What am I not  
looking at?

Thanks much!

--  
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/789b52f2-0e36-407b-9c83-aeba1987c655%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/789b52f2-0e36-407b-9c83-aeba1987c655%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, 1:27am UTC](https://discuss.elastic.co/t/better-phrase-suggestions-for-spelling-mistakes/17657/2 "2017-07-06T01:27:47Z")

</div>


