Check whether document returned is from a read or a write index

I have a requirement where I want to delete the documents which match the query but only if they are in the read index , if it is in a write index I don't want the documents to be deleted.
Below query deletes irrespective of whether read or write index.
Iam using the delete by query api

Post /(alias name)/_delete_by_query
"query": {
"term": {
"max_docs": 1,
"sort": [
"dateField": {
"order": "asc"
Can you please tel me know if the query can be changed in a way it deletes only from read index.

Thank you

I believe you would need to explicitly list the indices to delete from rather than using an alias that includes the current write index.

1 Like

There are numerous read index so , listing all would be a problem.
Is there a way to exclude the write index as there is just one write index

No there is not.

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