danielberkompas / elasticsearch-elixir

No-nonsense Elasticsearch library for Elixir
MIT License
422 stars 73 forks source link

support bulk delete requests #115

Open ckoch-cars opened 1 year ago

ckoch-cars commented 1 year ago

When the encoded struct 'document' is appended to a bulk request performing a delete operation, it causes the bulk request to fail.

As a failing curl:

curl -X PUT "localhost:9200/my-test-index/_bulk?pretty" -v -H 'Content-Type: application/json' -d'
{"delete":{"_id":"8dc97b1d-55f0-4651-810f-ca7c23fa7c59","_index":"my-test-index"}}
{"struct":null,"document":null,"body":null}
'
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Malformed action/metadata line [3], expected START_OBJECT or END_OBJECT but found [VALUE_NULL]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Malformed action/metadata line [3], expected START_OBJECT or END_OBJECT but found [VALUE_NULL]"
  },
  "status" : 400
}

As a success curl:

curl -X PUT "localhost:9200/my-test-index/_bulk?pretty" -v -H 'Content-Type: application/json' -d'
{"delete":{"_id":"8dc97b1d-55f0-4651-810f-ca7c23fa7c59","_index":"my-test-index"}}
'
{
  "took" : 0,
  "errors" : true,
  "items" : [
    {
      "delete" : {
        "_index" : "my-test-index",
        "_type" : "_doc",
        "_id" : "8dc97b1d-55f0-4651-810f-ca7c23fa7c59",
        "status" : 404,
        "error" : {
          "type" : "index_not_found_exception",
          "reason" : "no such index [my-test-index]",
          "resource.type" : "index_expression",
          "resource.id" : "my-test-index",
          "index_uuid" : "_na_",
          "index" : "my-test-index"
        }
      }
    }
  ]
}