# Is there any way to search for only one element from an array?

**URL:** <https://discuss.elastic.co/t/is-there-any-way-to-search-for-only-one-element-from-an-array/203851>\
**Category:** Elasticsearch\
**Created:** [October 16, 2019, 1:46pm UTC](https://discuss.elastic.co/t/is-there-any-way-to-search-for-only-one-element-from-an-array/203851 "2019-10-16T13:46:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nirajan](https://avatars.discourse-cdn.com/v4/letter/n/6bbea6/32.png) [@Nirajan](https://discuss.elastic.co/u/Nirajan)\
**Post date:** [October 16, 2019, 1:46pm UTC](https://discuss.elastic.co/t/is-there-any-way-to-search-for-only-one-element-from-an-array/203851/1 "2019-10-16T13:46:09Z")

</div>

Hello Everyone,

I am searching for any suggestions that would get me only one element from an array in Elasticsearch index.

I have tried the composite aggregation, nested aggregation and nested query but all of these approaches returns all the elements of an array.

lets say i have a field named "parameters" and it has other nested fields such as "ID" and "Value".  
The documents looks like:

"parameters": [  
{  
"ID": 101,  
"Value": 0.25  
},  
{  
"ID": 102,  
"Value": 0.38  
}  
]

so i would like to get the data from a "value" field with "ID": 101.  
The answer should be 0.25. But i am getting all the data from the array including 0.38 which is irrelevant.

The Query i used is:

GET test\_index/\_search  
{  
"query" : {  
"match" : { "ID" : "101" }  
},  
"aggs":{  
"comp":{  
"composite": {  
"size" : 10000,  
"sources": [  
{  
"name": { "terms": {"field":"name.keyword"} }  
},  
{  
"speed": { "terms": { "field": "parameters.Value"} }  
}  
]  
}  
}  
}  
}

Any suggestions would be very much appreciated.

Best Regards,  
Nirajan

---

<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:** [November 13, 2019, 1:58pm UTC](https://discuss.elastic.co/t/is-there-any-way-to-search-for-only-one-element-from-an-array/203851/2 "2019-11-13T13:58:16Z")

</div>

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