# Filter by nested

**URL:** https://discuss.elastic.co/t/filter-by-nested/136501
**Category:** Elasticsearch
**Created:** [June 19, 2018, 1:49pm UTC](https://discuss.elastic.co/t/filter-by-nested/136501 "2018-06-19T13:49:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![huli0401](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/huli0401/32/32423_2.png) [@huli0401](https://discuss.elastic.co/u/huli0401)
#### Post date: [June 19, 2018, 1:49pm UTC](https://discuss.elastic.co/t/filter-by-nested/136501/1 "2018-06-19T13:49:41Z")

</div>

Hi,  
I am trying to filter accomodations by date.

mapping:

```
{"_doc":{"_source":{"enabled":true},"properties":{"object":{"properties":{"id""{"type":"integer","coerce":false},"capacity":{"type":"integer","coerce":false},"type_id":{"type":"integer","null_value":0,"coerce":false},"params":{"properties":{"param1":{"type":"integer","coerce":false},"param2":{"type":"integer","coerce":false},"param3":{"type":"integer","coerce":false},"param4":{"type":"integer","coerce":false}}}}},"unit":{"properties":{"id":{"type":"integer","coerce":false},"capacity":{"type":"integer","coerce":false},"type_id":{"type":"integer","null_value":0,"coerce":false},"params":{"properties":{"param1":{"type":"integer","coerce":false},"param2":{"type":"integer","coerce":false},"param3":{"type":"integer","coerce":false},"param4":{"type":"integer","coerce":false}}},"date":{"type":"nested","dynamic":false,"properties":{"date":{"type":"date"},"price":{"type":"float","coerce":false},"start":{"type":"boolean"},"end":{"type":"boolean"},"status":{"type":"integer","coerce":false}}}}},"location":{"properties":{"gps":{"type":"geo_point"},"l1":{"type":"integer","coerce":false},"l2":{"type":"integer","coerce":false},"l3":{"type":"integer","coerce":false},"l4":{"type":"integer","coerce":false}}},"es_status":{"type":"integer","coerce":false},"fulltext":{"properties":{"sk":{"type":"text"},"cs":{"type":"text"}}}},"dynamic":false}}

```

in unit.date has multiple objects

{date:"2018-06-19", status:1},{date:"2018-06-20", status:1},{date:"2018-06-21", status:1}

How can i filter parent (root) document where i need multiple dates with status=1

I tried script in bool query also. loop is not working

---

<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: [July 17, 2018, 1:58pm UTC](https://discuss.elastic.co/t/filter-by-nested/136501/2 "2018-07-17T13:58:32Z")

</div>

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