# Match only the same tokens

**URL:** <https://discuss.elastic.co/t/match-only-the-same-tokens/117789>\
**Category:** Elasticsearch\
**Created:** [January 31, 2018, 10:52am UTC](https://discuss.elastic.co/t/match-only-the-same-tokens/117789 "2018-01-31T10:52:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kseniia\_Pelykh](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@Kseniia\_Pelykh](https://discuss.elastic.co/u/Kseniia_Pelykh)\
**Post date:** [January 31, 2018, 10:52am UTC](https://discuss.elastic.co/t/match-only-the-same-tokens/117789/1 "2018-01-31T10:52:49Z")

</div>

Hi,

I have this situation: I want to get documents that have the same tokens as my query. Not documents that can have more tokens that my query as match\_phrase does.  
I can't use term because I need to consider also synonyms and stopwords and also I have to ignore the position of tokens

Example:  
**brown fox** matches **brown fox**  
**brown fox** matches **fox brown**  
**brown fox** doesn't match **brown fox and dog**

Can you help me with this issue?

Thank you.

---

<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:** [January 31, 2018, 4:09pm UTC](https://discuss.elastic.co/t/match-only-the-same-tokens/117789/2 "2018-01-31T16:09:45Z")

</div>

Maybe the[fingerprint token filter](https://www.elastic.co/guide/en/elasticsearch/reference/master/analysis-fingerprint-tokenfilter.html) is what you need. It de-dups tokens though so `brown fox` would match `fox brown brown`

---

<div class="post-metadata">

**Author:** ![Kseniia\_Pelykh](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@Kseniia\_Pelykh](https://discuss.elastic.co/u/Kseniia_Pelykh)\
**Post date:** [February 9, 2018, 3:07pm UTC](https://discuss.elastic.co/t/match-only-the-same-tokens/117789/3 "2018-02-09T15:07:03Z")

</div>

Thank you a lot Mark,  
I will try this token.

---

<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:** [March 9, 2018, 3:12pm UTC](https://discuss.elastic.co/t/match-only-the-same-tokens/117789/4 "2018-03-09T15:12:36Z")

</div>

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