Delete documents by query with values from other index


I've created a similar question before which didn't get any answers so I create a new topic but with more information / code that maybe helps to understand what i'm after.

I've made an example of what I want to achive. I want to delete documents from dummyindex-stuff-1 if there is a document in dummyindex-cars-1 with that value in the Name-property. Does this require that I use .NET or Python API?

PUT dummyindex-stuff-1/_bulk?refresh

PUT dummyindex-cars-1/_bulk?refresh

// Johan

From what I understand in your ask, this doesn't require using a particular API like .NET or Python, but I think it cannot be done without using some sort of client logic. Assuming dummyindex-cars-1 is more or less static, you would iterate over all Name values (or if there is only one value per doc iterate over all docs) and delete the corresponding documents from the second index. In practise this would possible use some variation of the scroll API to get at the set of Name values, and then maybe batch some of those to perform the deletion e.g. with delete-by-query.

Thanks for answer :slight_smile:

I tried this and it seem to work except that don't find any info on if it's a possible to fetch an array of Doc Id's

POST dummyindex-stuff-1/_delete_by_query?scroll=1m
  "query": {
    "terms": {
      "objectName.keyword": {
        "index" : "dummyindex-cars-1",
        "id": "3",
        "path": "Name.keyword"

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