6

I want to delete many documents from elasticsearch that don't exist anymore on my database.

I know that to delete multiple documents (with ids 1,2,3 for example) we use :

curl -XDELETE localhost:9200/index/doc/ids=1,2,3

But I want to keep only those ids and delete the rest, it something like the following instruction in SQL.

DELETE FROM table1 WHERE id_column NOT IN (1,2,3);

Is there an equivalent of NOT IN in this case for elasticsearch?

1

1 Answer 1

7

It may be little dangerous but you can use delete by query. delete by query api

The query will be something like this:

query : {bool : { must_not : {ids : values : [1,2,3,... ]}}}

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

Comments

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.