# Elastic Search select doc only if all the values exist in the array

**URL:** <https://discuss.elastic.co/t/elastic-search-select-doc-only-if-all-the-values-exist-in-the-array/144505>\
**Category:** Elasticsearch\
**Created:** [August 15, 2018, 11:18am UTC](https://discuss.elastic.co/t/elastic-search-select-doc-only-if-all-the-values-exist-in-the-array/144505 "2018-08-15T11:18:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sajjad26](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@sajjad26](https://discuss.elastic.co/u/sajjad26)\
**Post date:** [August 15, 2018, 11:18am UTC](https://discuss.elastic.co/t/elastic-search-select-doc-only-if-all-the-values-exist-in-the-array/144505/1 "2018-08-15T11:18:56Z")

</div>

I have a bunch of products in my index and each product has this document structure  
{  
"id": 59342,  
"days": [  
{  
"date": "2018-08-14",  
"rate": 101.00  
}  
,  
{  
"date": "2018-08-15",  
"rate": 200.00  
}  
,  
{  
"date": "2018-08-18",  
"rate": 200.00  
}  
]  
}  
Now I want to get this document only if the `days` array contains all the dates between `2018-08-14` to `2018-08-16` . I have tried a couple of solutions but none have worked. Here is what I have so far  
{  
"query": {  
"nested": {  
"path": "days",  
"query": {  
"bool": {  
"must": [  
{  
"match": {  
"days.date": "2018-08-14"  
}  
},  
{  
"match": {  
"days.date": "2018-08-15"  
}  
},  
{  
"match": {  
"days.date": "2018-08-16"  
}  
}  
]  
}  
}  
}  
}  
}  
Here is the mapping data of the products  
{  
"mappings": {  
"products": {  
"properties": {  
"id": {  
"type": "integer"  
},  
"days": {  
"type": "nested",  
"properties": {  
"date": {  
"type": "date"  
},  
"rate": {  
"type": "double"  
}  
}  
}  
}  
}  
}  
}

---

<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:** [September 12, 2018, 11:18am UTC](https://discuss.elastic.co/t/elastic-search-select-doc-only-if-all-the-values-exist-in-the-array/144505/2 "2018-09-12T11:18:58Z")

</div>

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