# How to avoid multiple word matches without changing index\_option

**URL:** <https://discuss.elastic.co/t/how-to-avoid-multiple-word-matches-without-changing-index-option/92259>\
**Category:** Elasticsearch\
**Created:** [July 7, 2017, 12:02pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-word-matches-without-changing-index-option/92259 "2017-07-07T12:02:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sid\_1199](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sid\_1199](https://discuss.elastic.co/u/sid_1199)\
**Post date:** [July 7, 2017, 12:02pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-word-matches-without-changing-index-option/92259/1 "2017-07-07T12:02:02Z")

</div>

I have a query running on my index as follows:

GET /index/type/\_search?search\_type=dfs\_query\_then\_fetch  
{  
"query": {  
"bool": {  
"must": [{"match": { "field": {"query":"search\_value","boost":2}}]  
}  
}  
}

Every time the search\_value is encountered, it gets boosted. I would like to to be boosted only once if encountered, or twice as per requirements. How can I avoid multiple boost given to matches?

The documentation says that if you change index\_option to docs, it will disable term frequencies. However, i cannot use match\_phrase option then.  
Thanks a lot for your opinion and ideas!

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [July 7, 2017, 12:23pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-word-matches-without-changing-index-option/92259/2 "2017-07-07T12:23:13Z")

</div>

The boost is applied to the score of the match query so it's only applied once per matching document.  
Though the score of the `match` query takes the frequency of the "search\_value" into account so the score for a document with multiple occurrences of this term will be different than a document with a single occurrence.  
If you want to ignore the frequencies of the terms you can use the `boolean` similarity:  
[https://www.elastic.co/guide/en/elasticsearch/reference/master/similarity.html](https://www.elastic.co/guide/en/elasticsearch/reference/master/similarity.html)

---

<div class="post-metadata">

**Author:** ![sid\_1199](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sid\_1199](https://discuss.elastic.co/u/sid_1199)\
**Post date:** [July 7, 2017, 12:47pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-word-matches-without-changing-index-option/92259/3 "2017-07-07T12:47:46Z")

</div>

Thank you so much for your response. I changed my mapping to this:

PUT index\_name  
{  
"mappings" : {  
"type" : {  
"properties" : {  
"field\_name":{  
"type": "text",  
"similarity": "boolean"  
}  
}  
}  
}  
}

However, I am getting this error:

{  
"error": {  
"root\_cause": [  
{  
"type": "mapper\_parsing\_exception",  
"reason": "Unknown Similarity type [boolean] for field [skills]"  
}  
],  
"type": "mapper\_parsing\_exception",  
"reason": "Failed to parse mapping [candidate]: Unknown Similarity type [boolean] for field [skills]",  
"caused\_by": {  
"type": "mapper\_parsing\_exception",  
"reason": "Unknown Similarity type [boolean] for field [skills]"  
}  
},  
"status": 400  
}

Any help with this?

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [July 7, 2017, 12:52pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-word-matches-without-changing-index-option/92259/4 "2017-07-07T12:52:06Z")

</div>

The `boolean` similarity has been added in 5.4 so I guess you're using an older version ?

---

<div class="post-metadata">

**Author:** ![sid\_1199](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sid\_1199](https://discuss.elastic.co/u/sid_1199)\
**Post date:** [July 7, 2017, 12:55pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-word-matches-without-changing-index-option/92259/5 "2017-07-07T12:55:59Z")

</div>

I am using version 5.3. I guess that's why the issue is occurring.

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [July 7, 2017, 12:59pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-word-matches-without-changing-index-option/92259/6 "2017-07-07T12:59:03Z")

</div>

Yes, you should upgrade to 5.4 to be able to use this new similarity

---

<div class="post-metadata">

**Author:** ![sid\_1199](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sid\_1199](https://discuss.elastic.co/u/sid_1199)\
**Post date:** [July 7, 2017, 1:05pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-word-matches-without-changing-index-option/92259/7 "2017-07-07T13:05:39Z")

</div>

Will do. Thanks!

---

<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:** [August 4, 2017, 1:06pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-word-matches-without-changing-index-option/92259/8 "2017-08-04T13:06:07Z")

</div>

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