Zatvobor / tirexs

An Elixir flavored HTTP client and DSL library for Elasticsearch
https://hexdocs.pm/tirexs/api-reference.html
Other
429 stars 93 forks source link

Bulk operation incorrectly responds with :ok in case of failure #241

Open akurkin opened 8 years ago

akurkin commented 8 years ago

hello, trying to send bulk requests incorrectly responds as {:ok, 200} in case of failure.

Example code:

    data = ...
    payload = bulk([index: "dev", type: "entities"]) do
      index [data]
    end

    Tirexs.bump(payload)._bulk()

Example response:

10:34:53.148 [debug] response = {:ok, 200, %{errors: true, items: [%{create: %{_id: "AVaxY1hfg84TwY4g592U", _index: "dev", _type: "entities", error: %{caused_by: %{reason: "unknown property [day]", type: "illegal_argument_exception"}, 
reason: "failed to parse [timestamp]", type: "mapper_parsing_exception"}, status: 400}}], took: 12}}

Expected response:

{:error, 400, ... }

Thanks, Alex

OpakAlex commented 8 years ago

hi @akurkin ! Looks you have issue with mapping in ELK. Can you show me your index?

akurkin commented 8 years ago

yes, indeed I had an issue with mapping, I fixed that, but my point is that Tirexs was "routing" my code to "success" callback vs "failure", so I couldn't rely on the response from Tirexs, I had to pattern-match on actual response from elastic to figure out if response was good or not.

OpakAlex commented 8 years ago

yes, looks issue.