2016-03-05 253 views
0

我尝试使用https://www.npmjs.com/package/elasticsearch-deletebyquery通过查询删除文档。但所有的时间都让我回到了没有找到我的用法:elasticsearch deletebyquery return only only found

client.deleteByQuery({ 
    index: index, 
    type: type, 
    body: { 
    query: { 
     range: { 
     timeStamp: { 
      gte: "2016-03-05", 
      lt: "2016-03-06" 
     } 
     } 
    } 
    } 
}); 

返回时,我有:

Elasticsearch TRACE: 2016-03-05T11:48:52Z 
    -> DELETE ... 9200/amazontest/pageRanktest/_query 
    { 
    "query": { 
     "range": { 
     "timeStamp": { 
      "gte": "2016-03-05", 
      "lt": "2016-03-06" 
     } 
     } 
    } 
    } 
    <- 404 
    { 
    "found": false, 
    "_index": "amazontest", 
    "_type": "pageRanktest", 
    "_id": "_query" 

有什么不对?谁能帮帮我吗?

回答

0

从ES 2.0开始,按查询删除功能已经removed from the core,现在可作为插件使用。您可以在所有ES节点上安装delete-by-query插件,以便通过查询添加对删除文档的支持。

安装这样的插件:

bin/plugin install delete-by-query 

然后你就可以没有得到一个404

运行代码