# One filter depends on another filter

**URL:** https://discuss.elastic.co/t/one-filter-depends-on-another-filter/21103
**Category:** Elasticsearch
**Created:** [December 5, 2014, 11:29am UTC](https://discuss.elastic.co/t/one-filter-depends-on-another-filter/21103 "2014-12-05T11:29:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![blueskan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blueskan/32/1061_2.png) [@blueskan](https://discuss.elastic.co/u/blueskan)
#### Post date: [December 5, 2014, 11:29am UTC](https://discuss.elastic.co/t/one-filter-depends-on-another-filter/21103/1 "2014-12-05T11:29:14Z")

</div>

we're currently developing a project for our company using ElasticSearch. However we are at a hurdle and need your help;

our columns are start\_date, finish\_date, min\_value, max\_value

if start\_date and finish\_date have no entry we want it automatically return 'true', however if there is an entry among start\_date and finish\_date we want to determine if its 'true' or 'false' according to the min\_value and max\_value that we've predetermined

We've tried this logic to offset our problem however it didn't work.

{  
nested:  
{  
path: "restriction\_intervals",  
query:  
{  
filtered:  
{  
filter:  
{  
bool: {  
should: [  
{  
not: {  
and: [  
{  
range: {  
"restriction\_intervals.start\_date": {  
lte: 50  
}  
}  
},  
{  
range: {  
"restriction\_intervals.finish\_date": {  
gte: 50  
}  
}  
}  
]  
}  
},  
{  
and: [  
{  
range: {  
"restriction\_intervals.start\_date": {  
lte: 50  
}  
}  
},  
{  
range: {  
"restriction\_intervals.finish\_date": {  
gte: 50  
}  
}  
},  
{  
range: {  
"restriction\_intervals.min\_value": {  
lte: 4  
}  
}  
},  
{  
range: {  
"restriction\_intervals.max\_value": {  
lte: 4  
}  
}  
}  
]  
}  
]  
}  
}  
}  
}  
}  
}

We look forward to your suggestions. Thank you.

---

<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 6, 2017, 12:45am UTC](https://discuss.elastic.co/t/one-filter-depends-on-another-filter/21103/2 "2017-07-06T00:45:37Z")

</div>


