# ES5: Combined range and terms filter?

**URL:** https://discuss.elastic.co/t/es5-combined-range-and-terms-filter/75667
**Category:** Elasticsearch
**Created:** [February 20, 2017, 5:36am UTC](https://discuss.elastic.co/t/es5-combined-range-and-terms-filter/75667 "2017-02-20T05:36:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![trisport88](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@trisport88](https://discuss.elastic.co/u/trisport88)
#### Post date: [February 20, 2017, 5:36am UTC](https://discuss.elastic.co/t/es5-combined-range-and-terms-filter/75667/1 "2017-02-20T05:36:59Z")

</div>

Hi,

I'm not sure how to write a query the should filter on range and term. I have tried this (without the dots!) but it does not work:

> {  
> ...."size": 8,  
> ...."query": {  
> ........"bool": {  
> ............"filter": {  
> ................"bool": {  
> ...................."must": {  
> ........................"range": {  
> ............................."timestamp": {  
> .................................."gte": 0,  
> .................................."lte": 8888888888  
> .............................}  
> .........................},  
> ........................."terms": {  
> ............................."myfield": ["aValue"]  
> .........................}  
> .....................}  
> .................}  
> .............},  
> ............."must": {  
> ................."query\_string": {  
> ....................."query": "something",  
> ....................."fields": ["description"]  
> .................}  
> .............}  
> .........}  
> ....}  
> }

Any pointers would be much appreciated.

Cheers,

Stuart

---

<div class="post-metadata">

### Author: ![trisport88](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@trisport88](https://discuss.elastic.co/u/trisport88)
#### Post date: [February 20, 2017, 6:14am UTC](https://discuss.elastic.co/t/es5-combined-range-and-terms-filter/75667/2 "2017-02-20T06:14:38Z")

</div>

Sorry, just found the solution myself. The must element should have been followed by a list.

---

<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, 2017, 6:14am UTC](https://discuss.elastic.co/t/es5-combined-range-and-terms-filter/75667/3 "2017-03-20T06:14:44Z")

</div>

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