elasticsearch match two fields elasticsearch match two fields elasticsearch elasticsearch

elasticsearch match two fields


For queries like yours bool filter is preferred over and filter. See here the whole story about this suggestion and why is considered to be more efficient.

These being said, I would choose to do it like this:

{  "query": {    "filtered": {      "filter": {        "bool": {          "must": [            {"term": {"a": -23.4807339}},            {"term": {"b": -46.60068}}          ]        }      }    }  }}


You can approach this with the and filter. For your example, something like:

{  "size": 100,  "query" : {"filtered" : {    "query" : {"match_all" : {}},    "filter" : {"and" : [      "term" : {"a": -23.4807339},      "term" : {"b": -46.60068}    ]}  }}}

Be sure to direct the query against the correct index and type. Note that I specified the size of the return set as 100 arbitrarily - you'd have to specify a value that fits your use case.

There's more on filtered queries here, and more on the and filter here.