Delete By Query (Dry Run)

I was looking to remove some bad fields from my documents and like this functionality but I don't see a dry run, test type option that would report back number of documents that would have been affected

Now obviously, I could make a copy of the index, and run it against that , but I was hoping that there was a "TEST" option that run's the DELETE but does not apply the actual changes.

I am working off this article as an example

POST body:
  "script": ctx._source.remove("XXXXXXXXXXX"),
  "query": {
    "bool": {
      "must": [
          "exists": {
            "field": "XXXXXXXXXXXXX"

If you switch the endpoint from _update_by_query to _search and remove the
top level script element you can see the docs it will try to hit.

Another option is to run reindex into a new index with the same query and
look at the results. You can use the size parameter to stop after a certain
number of changes for faster testing.

yah I thought about the _search suggestion, one of my earlier tests was falling on a Max field value.

No worries, thought that making a copy was the only real way to test. Though my indexes are pretty large.

I think I will just work carefully on live data and in major issues restore one of my snapshots from S3. Just was hopping to avoid that .


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.