gpt4 book ai didi

Elasticsearch 2.2 : delete documents by query

转载 作者:行者123 更新时间:2023-11-29 02:52:26 26 4
gpt4 key购买 nike

我正在尝试从 Elasticsearch 中删除一些文档。

我有这些要求:

IDX=logstash-2016.02.13

curl -XGET "http://localhost:9200/$IDX/fg400/_search" -d '{
"query" : {
"term" : {
"action" : "start"
}
}
}' | python -m json.tool

这个读取查询给出:

{
"_shards": {
"failed": 0,
"successful": 5,
"total": 5
},
"hits": {
"hits": [
{
"_id": "AVLcXJrLLFxTvjNEoqDO",
"_index": "logstash-2016.02.13",
"_score": 3.4307306,
"_source": {
"@timestamp": "2016-02-13T20:40:00.000Z",
"@version": "1",
"action": "start", <------
...
],
"max_score": 3.4307306,
"total": 146511
},
"timed_out": false,
"took": 13
}

现在我这样说是因为我想删除一些:

curl -XDELETE "http://localhost:9200/${IDX}/fg400/_query" -d '{
"query" : {
"term" : {
"action" : "start"
}
}
}' | python -m json.tool

这给出了以下输出:

{
"_id": "_query",
"_index": "logstash-2016.02.13",
"_shards": {
"failed": 0,
"successful": 1,
"total": 2
},
"_type": "fg400",
"_version": 1,
"found": false
}

为什么我不能在使用 GET 之前删除我首先找到的内容?

最佳答案

Delete by query在2.0以后变成了一个插件。为了使用此功能,您需要安装插件 https://www.elastic.co/guide/en/elasticsearch/plugins/2.2/delete-by-query-usage.html

或者 Elastic 建议您执行查询以获取 ID,然后对结果按 ID 进行删除。

关于 Elasticsearch 2.2 : delete documents by query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35463164/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com