0

我正在升级到 elasticsearch 5.2 并有以下查询,现在由于“缺失”过滤器已弃用而失败:

{
    "query": {
      "bool": {
        "should": [
          {
            "missing": {
              "field": "birthday"
            }
          },
          {
           "range": {
             "birthday": {
               "lte": "20131231"
             }
           }
          }
        ]
      }
    }
  }

因此,我正在寻找缺少生日字段或生日小于 2013 年 12 月 31 日的文档。建议替换 "missing" 是使用 "must_not"。我明白了,但是我现在如何执行与以前相同的“或”查询?我有:

{
  "query": {
    "bool": {
      "should": {
        "range": {
          "birthday": {
            "lte": "20131231"
          }
        }
      },
      "must_not": {
        "exists": {
          "field": "birthday"
        }
      }
    }
  }
}
4

1 回答 1

0

你在正确的道路上,几乎在那里:

{
  "query": {
    "bool": {
      "should": [
        {
          "range": {
            "birthday": {
              "lte": "20131231"
            }
          }
        },
        {
          "bool": {
            "must_not": {
              "exists": {
                "field": "birthday"
              }
            }
          }
        }
      ]
    }
  }
}
于 2017-02-26T05:37:44.773 回答