The query for one field is not equal to another field in elasticsearch

How can I query or filter for one field not equal to another field? i.e. where document1.city1.name is not equal to document1.city2.name.

Some version of this? http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-script-fields.html

+7
elasticsearch
source share
1 answer

Yes, for this you need to use a script filter

{ "filtered": { "filter": { "script": { "script": "doc['field1'].value != doc['field2'].value" } } } } 

You can find more information here.

+10
source share

All Articles