# Fetching only matching elements from an array in Elasticsearch

**URL:** <https://discuss.elastic.co/t/fetching-only-matching-elements-from-an-array-in-elasticsearch/189231>\
**Category:** Elasticsearch\
**Created:** [July 7, 2019, 3:46am UTC](https://discuss.elastic.co/t/fetching-only-matching-elements-from-an-array-in-elasticsearch/189231 "2019-07-07T03:46:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![darsan55](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@darsan55](https://discuss.elastic.co/u/darsan55)\
**Post date:** [July 7, 2019, 3:46am UTC](https://discuss.elastic.co/t/fetching-only-matching-elements-from-an-array-in-elasticsearch/189231/1 "2019-07-07T03:46:42Z")

</div>

- I have an String array (not nested type) . Where i want only values
- which all are matching only not full array.

- Lets say i have ['a','b','c','d']. But in return i want only  
['a','b'] which will matching with my query.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 7, 2019, 6:40am UTC](https://discuss.elastic.co/t/fetching-only-matching-elements-from-an-array-in-elasticsearch/189231/2 "2019-07-07T06:40:50Z")

</div>

I don't think you can.

But I might have misunderstood your question.

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

---

<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:** [August 4, 2019, 6:41am UTC](https://discuss.elastic.co/t/fetching-only-matching-elements-from-an-array-in-elasticsearch/189231/3 "2019-08-04T06:41:05Z")

</div>

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