# Synonyms and relevance

**URL:** <https://discuss.elastic.co/t/synonyms-and-relevance/58582>\
**Category:** Elasticsearch\
**Created:** [August 22, 2016, 1:44pm UTC](https://discuss.elastic.co/t/synonyms-and-relevance/58582 "2016-08-22T13:44:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![richetdan](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@richetdan](https://discuss.elastic.co/u/richetdan)\
**Post date:** [August 22, 2016, 1:44pm UTC](https://discuss.elastic.co/t/synonyms-and-relevance/58582/1 "2016-08-22T13:44:17Z")

</div>

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-

---

<div class="post-metadata">

**Author:** ![richetdan](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@richetdan](https://discuss.elastic.co/u/richetdan)\
**Post date:** [August 23, 2016, 10:47am UTC](https://discuss.elastic.co/t/synonyms-and-relevance/58582/2 "2016-08-23T10:47:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [August 23, 2016, 11:09am UTC](https://discuss.elastic.co/t/synonyms-and-relevance/58582/3 "2016-08-23T11:09:05Z")

</div>

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](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](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-request-rescore.html)

---

<div class="post-metadata">

**Author:** ![richetdan](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@richetdan](https://discuss.elastic.co/u/richetdan)\
**Post date:** [August 23, 2016, 3:36pm UTC](https://discuss.elastic.co/t/synonyms-and-relevance/58582/4 "2016-08-23T15:36:19Z")

</div>

thank you very much for your contribution, Mark

-daniele-

---

<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 5, 2017, 10:25pm UTC](https://discuss.elastic.co/t/synonyms-and-relevance/58582/5 "2017-07-05T22:25:49Z")

</div>


