2016-03-05 92 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

運行代碼