I am trying to delete the docs from my index whose id is greater that 1500001. i have copied the code from the elastic documentation but it is not giving me any results. The code is
POST /us_data_master/_delete_by_query
{
"query": {
"range" : {
"id" : {
"gte" : 1500001
}
}
}
}
the response i get is
{
"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
}
i don't understand what is the problem. Looking forward for help
Thanks
Edit 1:
The mapping as requested is
{
"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
}
}
}
}
}
}
}
I'm guessing you are using Kibana. There is an additional empty line after POST and the query you have as below:
POST /us_data_master/_delete_by_query
<------ Remove this space
{
"query": {
"range" : {
"id" : {
"gte" : 1500001
}
}
}
}
Below is how it should be:
POST /us_data_master/_delete_by_query
{
"query": {
"range" : {
"id" : {
"gte" : 1500001
}
}
}
}
That should resolve the issue.