1

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
            }
          }
        }
      }
    }
  }
}
4
  • Which version of ES are you using? Also could you share the mapping details? Just want to check the datatype of id Commented Mar 20, 2020 at 21:39
  • i am using ES 7.6 Commented Mar 20, 2020 at 21:40
  • @OpsterESNinja-Kamal added the mapping Commented Mar 20, 2020 at 21:42
  • :) Please check the answer. That should resolve your issue. Commented Mar 20, 2020 at 21:44

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Anytime!! Also feel free to accept the answer too. Just click the right greyed arrow just under the upvote button you did.
Also can you help with this question as well stackoverflow.com/questions/60771999/…
@kool_Coder Could you let me know what is it that you'd want in that question. You seem to have accepted the answer for that question. If the question you have is different from the one you've asked, could you please create a new question.
Sorry these 2 questions are linked. stackoverflow.com/questions/60773403/…
@kool_Coder Got it. I'll answer it and let you know in that link itself!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.