Search code examples
elasticsearchelasticsearch-dsl

Elasticsearch - How to combine bool and range filters


I would like to combine this bool filter:

{
  "query": {
    "bool": {
      "filter": {
        "term": {
          "tp_operacao": "D"
        }}}}}

and this range filter:

{
  "query": {
    "range": {
      "nr_autorizacao": {
        "gte": 0
  }}}}

How can I do that?


Solution

  • Just put filter as array

     {
      "query": {
        "bool": {
          "filter": [
            {
              "term": {
                "tp_operacao": "D"
              }
            },
            {
              "range": {
                "nr_autorizacao": {
                  "gte": 0
                }
              }
            }
          ]
        }
      }
    }