我正在尝试从ID大于1500001的索引中删除文档。我已经从 flex 文档中复制了代码,但是没有给我任何结果。该代码是
POST /us_data_master/_delete_by_query
{
"query": {
"range" : {
"id" : {
"gte" : 1500001
}
}
}
}
我得到的回应是
{
"error" : {
"root_cause" : [
{
"type" : "action_request_validation_exception",
"reason" : "Validation Failed: 1: query is missing;"
}
],
"type" : "action_request_validation_exception",
"reason" : "Validation Failed: 1: query is missing;"
},
"status" : 400
}
我不明白是什么问题。期待帮助
谢谢
编辑1:
要求的映射是
{
"mapping": {
"_doc": {
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"address": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"city_code": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"contact_no": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"date_added": {
"type": "date"
},
"date_updated": {
"type": "date"
},
"featured": {
"type": "long"
},
"id": {
"type": "long"
},
"location_id": {
"type": "long"
},
"main_cate": {
"type": "long"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"slug": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"source": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"state_code": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"status": {
"type": "long"
},
"zip_code": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
最佳答案
我猜您正在使用Kibana。 POST和查询之后还有一个空行,如下所示:
POST /us_data_master/_delete_by_query
<------ Remove this space
{
"query": {
"range" : {
"id" : {
"gte" : 1500001
}
}
}
}
下面是应该如何:
POST /us_data_master/_delete_by_query
{
"query": {
"range" : {
"id" : {
"gte" : 1500001
}
}
}
}
那应该解决问题。
关于elasticsearch - ElasticSearch按查询删除不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/60781326/