elasticsearch 5:[过滤器]中START_OBJECT的未知密钥

时间:2016-12-06 13:12:29

标签: elasticsearch

我试图从elasticsearch 1.7迁移到5.1,我遇到了一个问题:

curl -XGET http://127.0.0.1:9200/openlist_ru-formulars/formular/_search?pretty=true -d '{
    "filter": [
        { "range": { "born": { "gte": "1874" }}}
    ]
}'

并回答:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "Unknown key for a START_OBJECT in [filters].",
        "line" : 2,
        "col" : 12
      }
    ],
    "type" : "parsing_exception",
    "reason" : "Unknown key for a START_OBJECT in [filters].",
    "line" : 2,
    "col" : 12
  },
  "status" : 400
}

我整天都在使用Google,但仍然无法回答它的含义。请帮忙。

1 个答案:

答案 0 :(得分:33)

看起来5.1版本的DSL结构已经改变,这个查询很好:

{
    "query": { 
        "bool": {
            "filter": [{
                "range": {
                    "born": {
                        "gte": "1874"
                    }
                }
            }]
        }
    }
}