Synonyms and relevance

I am testing the usage of a custom analyzer with a Synonym token filter.
At search time I would like to have more relevance on documents which match the original term rather than the synonym. Which approach I have to use?

Thanks in advance

-daniele-

I thought this solution:
-the synonym analyzer is applied only at query time
-using a boolean query combining 2 query, one with a must clause using analyzer with synonyms and onother with should clause wich use analyzer without synonyms. In this way terms which match both clauses takes more relevance.
Does it make sense? There are side effects?
Someone can help?

The approach of running user search string input as multiple clauses (fuzzy, phrase, synonym) simultaneously as a big should array is valid. The more of the clauses that match the better and you could even artificially apply boost settings to the preferred interpretations.

Also consider that some queries are more expensive than others [1] and that the more expensive ones such as phrase queries can be run more cheaply if they are only applied to the top N matches produced by cheaper queries by using the rescore [2] query type.

[1] https://www.elastic.co/blog/elasticsearch-queries-or-term-queries-are-really-fast
[2] https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-request-rescore.html

1 Like

thank you very much for your contribution, Mark

-daniele-

1 Like