# How to search for a single object of array with 2 must

**URL:** <https://discuss.elastic.co/t/how-to-search-for-a-single-object-of-array-with-2-must/169162>\
**Category:** Elasticsearch\
**Created:** [February 20, 2019, 8:29am UTC](https://discuss.elastic.co/t/how-to-search-for-a-single-object-of-array-with-2-must/169162 "2019-02-20T08:29:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![peteratef](https://avatars.discourse-cdn.com/v4/letter/p/7c8e57/32.png) [@peteratef](https://discuss.elastic.co/u/peteratef)\
**Post date:** [February 20, 2019, 8:29am UTC](https://discuss.elastic.co/t/how-to-search-for-a-single-object-of-array-with-2-must/169162/1 "2019-02-20T08:29:33Z")

</div>

i am trying to get result with conditions that matched single object of an array for example  
1-find tag truck whose color is red  
suppose to return the whole object,  
2- find a tag truck whose color is pink  
suppose to return nothing

{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 1,  
"successful": 1,  
"failed": 0  
},  
"hits": {  
"total": 2,  
"max\_score": 10.000583,  
"hits": [  
{  
"\_index": "atun",  
"\_type": "log-test",  
"\_id": "AWiy9lASsFWHgqVusudO",  
"\_score": 10.000583,  
"\_source": {  
"user\_id": "5c488a774b230e00b235a592",  
"job\_id": "5c56b8454b230e49d192d460",  
"timestamp": 1549187292,  
"plugin\_name": "5c4d61cb4b230e02f77d24e0",  
"plugin\_output": {  
"chunk\_index": 0,  
"id": 6,  
"attributes": [  
{  
"tag": "person",  
"color": [  
"Black",  
"Pink",  
"blue"  
],  
"size": [  
2000,  
4000  
],  
"time": [  
7,  
150  
],  
"speed": 15  
},  
{  
"tag": "truck",  
"color": [  
"Blue",  
"red"  
],  
"size": [  
8000,  
10000  
],  
"time": [  
7,  
150  
],  
"speed": 50  
}  
]  
},  
"input\_source": "5c4d62064b230e02f77d24e2",  
"frame\_number": 3401,  
"frame\_path": "27c3864e-d180-42d2-add1-6699566a6997\_1549187334.png"  
}  
},  
{  
"\_index": "atun",  
"\_type": "log-test",  
"\_id": "AWizCW7IsFWHgqVusudQ",  
"\_score": 10.000583,  
"\_source": {  
"user\_id": "5c488a774b230e00b235a592",  
"job\_id": "5c56b8454b230e49d192d460",  
"timestamp": 1549187292,  
"plugin\_name": "5c4d61cb4b230e02f77d24e0",  
"plugin\_output": {  
"chunk\_index": 1,  
"id": 0,  
"attributes": [  
{  
"tag": "person",  
"color": [  
"Black",  
"Pink",  
"blue"  
],  
"size": [  
2000,  
4000  
],  
"time": [  
7,  
150  
],  
"speed": 15  
},  
{  
"tag": "truck",  
"color": [  
"Blue",  
"red"  
],  
"size": [  
8000,  
10000  
],  
"time": [  
7,  
150  
],  
"speed": 50  
}  
]  
},  
"input\_source": "5c4d62064b230e02f77d24e2",  
"frame\_number": 3401,  
"frame\_path": "27c3864e-d180-42d2-add1-6699566a6997\_1549187334.png"  
}  
}  
]  
}  
}

Thanks and best 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:** [March 20, 2019, 8:29am UTC](https://discuss.elastic.co/t/how-to-search-for-a-single-object-of-array-with-2-must/169162/2 "2019-03-20T08:29:34Z")

</div>

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