Antonym filtering in Elasticsearch

Viewed 324

If I search for with a query string that contains "extrahepatisch" i do not want to find documents with the word "intrahepatisch" which is a antonym.

I have a list with such antonym pairs. What is the best way to make elasticsearch use the antonym list?

2 Answers

You could achieve this with the Querqy Plugin and its Common Rules Rewriter.

To exclude "intrahepatisch" from the result list, you would have a rule like:

extrahepatisch => FILTER: -intrahepatisch

If you want to keep the results for "intrahepatisch" but you want them to have a lower relevance score so that they appear at the end of the result list, you could just "downvote" them:

extrahepatisch => DOWN(20): intrahepatisch

Related