# Filter on x% of matching words in field

**URL:** <https://discuss.elastic.co/t/filter-on-x-of-matching-words-in-field/7440>\
**Category:** Elasticsearch\
**Created:** [April 23, 2012, 10:17am UTC](https://discuss.elastic.co/t/filter-on-x-of-matching-words-in-field/7440 "2012-04-23T10:17:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bgossey](https://avatars.discourse-cdn.com/v4/letter/b/f14d63/32.png) [@bgossey](https://discuss.elastic.co/u/bgossey)\
**Post date:** [April 23, 2012, 10:17am UTC](https://discuss.elastic.co/t/filter-on-x-of-matching-words-in-field/7440/1 "2012-04-23T10:17:12Z")

</div>

Hello,

I want to implement the following filter for a certain field in my  
document.

If less than 65% of the words match, I want this document be filtered  
out. The order of words doesn't matter. For example:

field contains: "word1 word2 word3", query is "word1 word2" --\> a  
match, 66% (so not filtered out)  
field contains: "word1 word2 word3", query is "word2 word1" --\> a  
match, 66% (so not filtered out)  
field contains: "word1 word2 word3", query is "word1" --\> not a match,  
only 33% (so filtered out)  
field contains: "word1 word2", query is "word1" --\> not a match, only  
50% (so filtered out)  
field contains: "word1 word2", query is "word1 word2" --\> a match,  
100% (so not filtered out)

Does anybody has any suggestions on what analyzer I should use (id I  
need a special one) and/or what query I can use?

thanks,  
Bert Gossey

---

<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 6, 2017, 3:31am UTC](https://discuss.elastic.co/t/filter-on-x-of-matching-words-in-field/7440/2 "2017-07-06T03:31:22Z")

</div>

Closed on July 6, 2017, 3:31am UTC


