# Filtering with elasticsearch

**URL:** <https://discuss.elastic.co/t/filtering-with-elasticsearch/157085>\
**Category:** Elasticsearch\
**Created:** [November 16, 2018, 2:46pm UTC](https://discuss.elastic.co/t/filtering-with-elasticsearch/157085 "2018-11-16T14:46:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![easyoups](https://avatars.discourse-cdn.com/v4/letter/e/a3d4f5/32.png) [@easyoups](https://discuss.elastic.co/u/easyoups)\
**Post date:** [November 16, 2018, 2:46pm UTC](https://discuss.elastic.co/t/filtering-with-elasticsearch/157085/1 "2018-11-16T14:46:53Z")

</div>

Hello

I try to do something strange and to be franc I have no idea how to query it.  
Basically I want to filter an array by checking if values are in ES and conserving the order...

For instance : array = [123, 832, 108, 431]  
if ES has keys 431 and 832  
I want to return [832, 431]

I know that it is not what ES is made for... But It is what I'd like to do 🙂

Any idea ?

---

<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 19, 2018, 6:14pm UTC](https://discuss.elastic.co/t/filtering-with-elasticsearch/157085/2 "2018-11-19T18:14:08Z")

</div>

I'm not sure if there is anything in elasticsearch that will give you exactly that.  
However, if you go via the regular query/filter route, highlights object will give you what matches. You may programatically transform it into whatever form you need it in.

---

<div class="post-metadata">

**Author:** ![easyoups](https://avatars.discourse-cdn.com/v4/letter/e/a3d4f5/32.png) [@easyoups](https://discuss.elastic.co/u/easyoups)\
**Post date:** [November 27, 2018, 9:35am UTC](https://discuss.elastic.co/t/filtering-with-elasticsearch/157085/3 "2018-11-27T09:35:32Z")

</div>

Thx... Indeed I was expecting for something simplier 🙂  
If I didn't find, I will do it on code side...

Regards

---

<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 25, 2018, 9:35am UTC](https://discuss.elastic.co/t/filtering-with-elasticsearch/157085/4 "2018-12-25T09:35:36Z")

</div>

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