Filtered bool vs Bool query : elasticsearch Filtered bool vs Bool query : elasticsearch elasticsearch elasticsearch

Filtered bool vs Bool query : elasticsearch


The first one uses the old 1.x query/filter syntax (i.e. filtered queries have been deprecated in favor of bool/filter).

The second one uses the new 2.x syntax but not in a filter context (i.e. you're using bool/must instead of bool/filter). The query with 2.x syntax which is equivalent to your first query (i.e. which runs in a filter context without score calculation = faster) would be this one:

{  "query": {    "bool": {      "filter": [        {          "term": {            "called_party_address_number": "1277478699"          }        },        {          "term": {            "original_sender_address_number": "8020564722"          }        },        {          "term": {            "cause_code": "573"          }        },        {          "range": {            "x_event_timestamp": {              "gt": "2016-07-13T13:51:03.749Z",              "lt": "2016-07-16T13:51:03.749Z"            }          }        }      ]    }  },  "from": 0,  "size": 10,  "sort": [    {      "x_event_timestamp": {        "order": "desc",        "ignore_unmapped": true      }    }  ]}