Inject Synonyms Direct Generator in phrase_suggester


(Moises Garcia Marquez) #1

Good afternoon, ES community. At the end of the documentation for the phrase suggester, is the following paragraph:

"pre_filter and post_filter can also be used to inject synonyms after candidates are generated. For instance for the query captain usq we might generate a candidate usa for term usq which is a synonym for america which allows to present captain america to the user if this phrase scores high enough.".

Following the given example right before paragraph, how can the direct generator be modified to inject synonyms?

I'm trying by creating an analyzer named "suggestion_synonyms" which uses a synonym token filter and passing this analyzer in the post_filter for the direct generatior, but with no success so far:

POST _search
{
"suggest": {
"text" : "obel prize",
"simple_phrase" : {
"phrase" : {
"field" : "title.trigram",
"size" : 1,
"direct_generator" : [ {
"field" : "title.trigram",
"suggest_mode" : "always"
}, {
"field" : "title.reverse",
"suggest_mode" : "always",
"pre_filter" : "reverse",
"post_filter" : "reverse"
}, {
"field" : "title.trigram",
"suggest_mode" : "always",
"post_filter" : "suggestion_synonyms"
} ]
}
}
}
}

Am I missing something in the direct_generator and its pre and post filter's logic?

Thanks in advance for any light that you may shed on this.


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.