query for one field doesn't equal another field in elasticsearch

前端 未结 1 392
时光说笑
时光说笑 2020-12-17 14:50

How can I query for, or filter for, one field doesn\'t equal another field? i.e. where document1.city1.name not equal document1.city2.name.

Some version of this? ht

相关标签:
1条回答
  • 2020-12-17 15:26

    Yes , you will need to use script filter to achieve this

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

    You can find more information here

    0 讨论(0)
提交回复
热议问题