# Exact phrase matching in any word order, but restricts words not in query

**URL:** <https://discuss.elastic.co/t/exact-phrase-matching-in-any-word-order-but-restricts-words-not-in-query/12814>\
**Category:** Elasticsearch\
**Created:** [July 16, 2013, 9:35pm UTC](https://discuss.elastic.co/t/exact-phrase-matching-in-any-word-order-but-restricts-words-not-in-query/12814 "2013-07-16T21:35:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![waysidekoi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waysidekoi/32/2225_2.png) [@waysidekoi](https://discuss.elastic.co/u/waysidekoi)\
**Post date:** [July 16, 2013, 9:35pm UTC](https://discuss.elastic.co/t/exact-phrase-matching-in-any-word-order-but-restricts-words-not-in-query/12814/1 "2013-07-16T21:35:17Z")

</div>

I would like to query for 'apple pie' and return the result 'apple pie' as well as 'pie apple', but I want to restrict any results such as 'apple pie crumb cake' or 'brown apple pie'. Is there some kind of: 'result must match query exactly' or some way to use the score as an indicator for a perfect/exact match?

Default operator 'and' is perfect, but it also retrieves results that do not exactly match.

'not\_analyze' or tokenizing the fields as 'keyword' doesn't allow me to query for the item in reverse, ie: 'apple pie' works, but 'pie apple' does not.

Wayne

---

<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, 2:26am UTC](https://discuss.elastic.co/t/exact-phrase-matching-in-any-word-order-but-restricts-words-not-in-query/12814/2 "2017-07-06T02:26:06Z")

</div>


