How to delete multiple documents from your index


#1

Hi,

Using the example below how do I delete all documents within an index that match the actype field i.e all REF-3?

{
"_index": "index-names-2018.08.27",
"_type": "doc",
"_id": "XOod0mUBf6rT7tCrMDeP",
"_version": 1,
"_score": null,
"_source": {
"alertid": 6860,
"@version": "1",
"description": "description heret",
"@timestamp": "2018-08-27T07:44:14.000Z",
"commentary": "Commentary",
"actype": "REF-3",

Thanks in advance

Martin


(Jon Budzenski) #2

You're looking for the delete_by_query api, https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html. I'd give the query a run first before deleting to make sure verything looks okay :slight_smile:

curl -X POST "localhost:9200/index-names-2018.08.27/_delete_by_query" -H 'Content-Type: application/json' -d'
{
  "query": { 
    "match": {
      "actype": "REF-3"
    }
  }
}
'

#3

Hi,

This was exactly what I've been looking for. Many thanks


(system) #4

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