我是Elasticsearch的新手,試圖找出一種方法來刪除包含時間戳爲其值的字段的文檔。Elasticsearch根據字段值刪除文檔
我有一個文檔,其字段名爲lastmodifiedtime。此字段的類型是長且被用於存儲時間戳(因爲EPOCH。當然,1486709502毫秒即數量)。
現在我有一個用例,我需要刪除lastmodifiedtime超過一天的所有文檔。於是我找出對應有一天年長時間timstamp值,然後嘗試刪除的文件。
我想REST調用如下
DELETE http://localhost:9200/testindex/testtype/_query
"query": {
"term" : {
"lastmodifiedtime" : {
"lte": 1486709504
}
}
}
但是,得到如下回應:
{
"found": false,
"_index": "testindex",
"_type": "testtype",
"_id": "_query",
"_version": 4,
"result": "not_found",
"_shards":
{
"total": 2,
"successful": 1,
"failed": 0
}
}
能否請你幫我該如何處理這種情況?
這只是意味着你的查詢沒有返回任何比賽。你確定文件是否存在(只運行文件查詢最後修改時間LTE 1486709504並檢查是否返回結果 –
如果您使用的是> = 5.2 elasticsearch試試這個:https://www.elastic.co/guide/en/elasticsearch /reference/current/docs-delete-by-query.html – rad11
'1486709504'是秒數,'1486709504000'是毫秒數。試一試。 – Val