ElasticSearch 按查询删除不起作用
ElasticSearch Delete by Query is not working
我正在尝试从我的索引中删除 ID 大于 1500001 的文档。我已经从弹性文档中复制了代码,但它没有给我任何结果。密码是
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
}
}
}
}
这应该可以解决问题。
我正在尝试从我的索引中删除 ID 大于 1500001 的文档。我已经从弹性文档中复制了代码,但它没有给我任何结果。密码是
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
}
}
}
}
这应该可以解决问题。