# Not able to Combine Interval Queries with Other Bool Filter

**URL:** <https://discuss.elastic.co/t/not-able-to-combine-interval-queries-with-other-bool-filter/201195>\
**Category:** Elasticsearch\
**Created:** [September 26, 2019, 9:27am UTC](https://discuss.elastic.co/t/not-able-to-combine-interval-queries-with-other-bool-filter/201195 "2019-09-26T09:27:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![harisc4u](https://avatars.discourse-cdn.com/v4/letter/h/9d8465/32.png) [@harisc4u](https://discuss.elastic.co/u/harisc4u)\
**Post date:** [September 26, 2019, 9:27am UTC](https://discuss.elastic.co/t/not-able-to-combine-interval-queries-with-other-bool-filter/201195/1 "2019-09-26T09:27:09Z")

</div>

I am using Elastic intervals Queries [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-intervals-query.html#query-dsl-intervals-query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-intervals-query.html#query-dsl-intervals-query)

I want to combine interval queries with another range filter But I am not able to apply other filters.

Here is my sample query

```
  {
  "query": {
    "bool": {
      "filter": {
        "range": {
          "session_end_time": {
            "from": "2019-09-11T00:00:00.000Z",
            "to": "2019-09-12T23:59:59.999Z",
            "include_lower": true,
            "include_upper": true,
            "format": "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
          }
        }
      }
    },
    "intervals": {
      "ordered_session_events": {
        "any_of": {
          "intervals": [
            {
              "match": {
                "query": "text1 text2 text3",
                "max_gaps": -1,
                "ordered": true
              }
            }
          ]
        }
      }
    }
  },
  "aggregations": {
    "count": {
      "cardinality": {
        "field": "sessn_id"
      }
    }
  }
}

```

I am getting below error

{  
"error": {  
"root\_cause": [  
{  
"type": "parsing\_exception",  
"reason": "[bool] malformed query, expected [END\_OBJECT] but found [FIELD\_NAME]",  
"line": 16,  
"col": 9  
}  
],  
"type": "parsing\_exception",  
"reason": "[bool] malformed query, expected [END\_OBJECT] but found [FIELD\_NAME]",  
"line": 16,  
"col": 9  
},  
"status": 400  
}

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 26, 2019, 1:58pm UTC](https://discuss.elastic.co/t/not-able-to-combine-interval-queries-with-other-bool-filter/201195/2 "2019-09-26T13:58:31Z")

</div>

the structure of the bool query needs to be fixed. the `filter` part of the `bool` query needs to be an array, that contains the `range` and the `intervals` within the `filter` field.

---

<div class="post-metadata">

**Author:** ![harisc4u](https://avatars.discourse-cdn.com/v4/letter/h/9d8465/32.png) [@harisc4u](https://discuss.elastic.co/u/harisc4u)\
**Post date:** [September 26, 2019, 2:42pm UTC](https://discuss.elastic.co/t/not-able-to-combine-interval-queries-with-other-bool-filter/201195/3 "2019-09-26T14:42:17Z")

</div>

Thanks, That Worked.

---

<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:** [October 24, 2019, 2:48pm UTC](https://discuss.elastic.co/t/not-able-to-combine-interval-queries-with-other-bool-filter/201195/4 "2019-10-24T14:48:06Z")

</div>

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