# Query range problem

**URL:** <https://discuss.elastic.co/t/query-range-problem/240150>\
**Category:** Elasticsearch\
**Created:** [July 7, 2020, 11:40am UTC](https://discuss.elastic.co/t/query-range-problem/240150 "2020-07-07T11:40:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![d.silwon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/d.silwon/32/65853_2.png) [@d.silwon](https://discuss.elastic.co/u/d.silwon)\
**Post date:** [July 7, 2020, 11:40am UTC](https://discuss.elastic.co/t/query-range-problem/240150/1 "2020-07-07T11:40:59Z")

</div>

Dears,

How to modify such query to add additional condition to first range "0nn"?

I need to find only such documents which meet such conditions:  
ci.a": { "gte": 0,"lte": 99} and ci.b like "(??1?) or (??3?) or (??5?) or (??7?) or (??9?)"

POST /log-2020-06-29/\_search?size=0  
{  
"query": {  
"bool": {  
"filter": [  
{  
"range": {  
"@timestamp": {  
"gte": "2020-06-29T07:22:01",  
"lte": "2020-06-29T11:31:01"  
}  
}  
}  
]  
}  
},  
"aggs": {  
"mti": {  
"filters": {  
"filters": {  
"0nn" : { "range": {"ci.a": { "gte": 0,"lte": 99}}},  
"4nn" : { "range": {"ci.a": { "gte": 400,"lte": 499}}},  
"1nn-2nn" : { "range": {"ci.a": { "gte": 100,"lte": 299}}},  
"9nn" : { "range": {"ci.a": { "gte": 900,"lte": 999}}}  
}  
}  
}  
}  
}

Regards,  
Daniel

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [July 7, 2020, 12:06pm UTC](https://discuss.elastic.co/t/query-range-problem/240150/2 "2020-07-07T12:06:28Z")

</div>

I'm not 100% sure what you are going for, but I'd look at the `wildcard` query. You might filter on a couple of them.

If you want to group the agg by them you can also do a `filters` agg.

---

<div class="post-metadata">

**Author:** ![d.silwon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/d.silwon/32/65853_2.png) [@d.silwon](https://discuss.elastic.co/u/d.silwon)\
**Post date:** [July 7, 2020, 12:51pm UTC](https://discuss.elastic.co/t/query-range-problem/240150/3 "2020-07-07T12:51:39Z")

</div>

In my query there is filter for such range:  
"0nn" : { "range": {"ci.a": { "gte": 0,"lte": 99}}}

I would like to put to this container less docs which meet additional condition:

```auto
          "query_string": {
            "query": "(??1?) or (??3?) or (??5?) or (??7?) or (??9?)",
            "default_field": "ci.b"

```

---

<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:** [August 4, 2020, 12:51pm UTC](https://discuss.elastic.co/t/query-range-problem/240150/4 "2020-08-04T12:51:40Z")

</div>

Closed on August 4, 2020, 12:51pm UTC

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