# Filter results with custom logic

**URL:** <https://discuss.elastic.co/t/filter-results-with-custom-logic/156301>\
**Category:** Elasticsearch\
**Created:** [November 12, 2018, 2:13pm UTC](https://discuss.elastic.co/t/filter-results-with-custom-logic/156301 "2018-11-12T14:13:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcelothebuilder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcelothebuilder/32/37522_2.png) [@marcelothebuilder](https://discuss.elastic.co/u/marcelothebuilder)\
**Post date:** [November 12, 2018, 2:13pm UTC](https://discuss.elastic.co/t/filter-results-with-custom-logic/156301/1 "2018-11-12T14:13:10Z")

</div>

I have multiple match\_phrase clauses. Is there a way to access the matching phrases (the match\_phrase results and which clauses matched) and their position for each document? I'm looking for a way to create a plugin or painless script to do that.

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [November 14, 2018, 8:18pm UTC](https://discuss.elastic.co/t/filter-results-with-custom-logic/156301/2 "2018-11-14T20:18:07Z")

</div>

The highlights object will typically return you all the occurrences of matches and the fields they match in.

---

<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:** [December 12, 2018, 8:18pm UTC](https://discuss.elastic.co/t/filter-results-with-custom-logic/156301/3 "2018-12-12T20:18:23Z")

</div>

Closed on December 12, 2018, 8:18pm UTC

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