0

Using the following ElasticSearch query to delete all documents with sourceId 1:

POST http://{{elasticip}}:9200/index2/index2_doc/_delete_by_query

{
  "query": {
    "match": {
      "sourceId": 1
    }
  }
}

What is the proper syntax of the body if I wanted to delete from sourceId 1, 2, and 3 all at once?

4
  • You can use terms query with multiple Ids or multiple match query in should clause Commented Oct 28, 2019 at 14:13
  • 1
    { "query" : { "bool" : { "filter" : { "terms" : { "sourceId" : [1,2,3] } } } } } Commented Oct 28, 2019 at 14:15
  • @Stpete111, you can try @LeBigCats;s answer Commented Oct 28, 2019 at 14:17
  • Hi @LeBigCat . Thanks! That syntax works. Are you sure you don't want to post that as the answer so I can mark it as the answer? Commented Oct 28, 2019 at 14:18

1 Answer 1

2

Use bool terms filter:

{ "query" : { "bool" : { "filter" : { "terms" : { "sourceId" : [1,2,3] } } } } }

note: jaspreet advices are also corrects.

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.