Better phrase suggestions for spelling mistakes


(Rahul Thathoo) #1

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/789b52f2-0e36-407b-9c83-aeba1987c655%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #2