Query Returns X, DELETE deletes less documents

I want to delete all documents with a specified category.

I can find 107 documents with:

POST /myb-all/access/_search?pretty
{
  "query": { "match": { "category": "Hit" } }
}

Which returns:

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 107,
    "max_score": null,
    "hits": [
      {
...

But DELETE doesn't delete them:

DELETE /myb-all/access/_search?pretty
{
  "query": { "match": { "category": "Hit" } }
}

It returns:

{
  "found": false,
  "_index": "myb-all",
  "_type": "access",
  "_id": "_search",
  "_version": 1,
  "result": "not_found",
  "_shards": {
    "total": 2,
    "successful": 1,
    "failed": 0
  }
}

Wrong syntax. See https://www.elastic.co/guide/en/elasticsearch/reference/5.1/docs-delete-by-query.html

_search is not correct here.

Thanks! There sure are a lotta examples out there.

So, for v5 it's:

POST myindex/mytype/_delete_by_query
{
  "query": { "match": { "myfield": "myvalue" } }
}

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