Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 981 Bytes

delete.md

File metadata and controls

51 lines (37 loc) · 981 Bytes

Deleting

A delete request allows us to delete document(s) from an index based on an id or query.

For example, to delete a single document by id in an index called places:

client.execute {
  deleteById("places", "3")
}

We can take this a step further by deleting using a query rather than directly by id. In this example we're deleting all bands where their type is pop.

client.execute {
  deleteByQuery("bands", termQuery("type", "pop"))
}

Bulk

Delete is bulk compatible so we can issue multiple requests at once:

client.bulk {
  deleteById("places", "4")
  deleteById("places", "5")
  deleteById("places", "6")
}

Index

To delete an entire index you can use deleteIndex:

client.execute {
  deleteIndex("places")
}

Or do delete all indices (careful!):

client.execute {
  deleteIndex("_all")
}