es:实现查询某个字段为固定值,另一个字段必须不能存在

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38750084/article/details/84797818

要求:查询出 positionName为空,hasJobRequest为1的数据

也可以尝试用must ,must_not ,exist:

{

  "query": {

    "bool": {

      "must_not": [

        {

          "match": {

            "hasJobRequest": 0

          }

        }

      ],

      "must": [

        {

          "exists": {

            "field": "positionName"

          }

        },

        {

          "range": {

            "id": {

              "gt": "90000",

              "lt": "110000"

            }

          }

        }

      ]

    }

  },

  "size": 10000

}

 

猜你喜欢

转载自blog.csdn.net/weixin_38750084/article/details/84797818