diff --git a/lib/snap/bulk/action.ex b/lib/snap/bulk/action.ex index 3cf7061..7a08dfd 100644 --- a/lib/snap/bulk/action.ex +++ b/lib/snap/bulk/action.ex @@ -124,7 +124,6 @@ defimpl Jason.Encoder, for: Snap.Bulk.Action.Update do %Snap.Bulk.Action.Update{ _index: index, _id: id, - doc_as_upsert: doc_as_upsert, require_alias: require_alias, routing: routing }, @@ -133,7 +132,6 @@ defimpl Jason.Encoder, for: Snap.Bulk.Action.Update do values = [ _index: index, _id: id, - doc_as_upsert: doc_as_upsert, require_alias: require_alias, routing: routing ] diff --git a/lib/snap/bulk/actions.ex b/lib/snap/bulk/actions.ex index 227a326..a239a06 100644 --- a/lib/snap/bulk/actions.ex +++ b/lib/snap/bulk/actions.ex @@ -42,7 +42,8 @@ defmodule Snap.Bulk.Actions do doc = action.doc doc_json = - %{doc: doc} + %{doc: doc, doc_as_upsert: action.doc_as_upsert} + |> Map.reject(fn {_key, value} -> is_nil(value) end) |> Jason.encode!() action_json = encode_action_command(action) diff --git a/mix.exs b/mix.exs index 6df0972..994ef35 100644 --- a/mix.exs +++ b/mix.exs @@ -3,7 +3,7 @@ defmodule Snap.MixProject do @original_github_url "https://github.com/breakroom/snap" @github_url "https://github.com/surgeventures/snap" - @version "0.10.2" + @version "0.10.3" def project do [ diff --git a/test/bulk/actions_test.exs b/test/bulk/actions_test.exs index b22c380..2b46324 100644 --- a/test/bulk/actions_test.exs +++ b/test/bulk/actions_test.exs @@ -18,6 +18,6 @@ defmodule Snap.Bulk.ActionsTest do encoded = Actions.encode(actions) |> IO.chardata_to_string() assert encoded == - "{\"index\":{\"_index\":\"foo\",\"routing\":\"bar\"}}\n{\"foo\":\"bar\"}\n{\"create\":{\"_index\":\"foo\",\"require_alias\":true,\"routing\":\"bar\"}}\n{\"foo\":\"bar\"}\n{\"update\":{\"_index\":\"foo\",\"_id\":2,\"doc_as_upsert\":true,\"routing\":\"bar\"}}\n{\"doc\":{\"foo\":\"bar\"}}\n{\"delete\":{\"_index\":\"foo\",\"_id\":1,\"routing\":\"bar\"}}\n" + "{\"index\":{\"_index\":\"foo\",\"routing\":\"bar\"}}\n{\"foo\":\"bar\"}\n{\"create\":{\"_index\":\"foo\",\"require_alias\":true,\"routing\":\"bar\"}}\n{\"foo\":\"bar\"}\n{\"update\":{\"_index\":\"foo\",\"_id\":2,\"routing\":\"bar\"}}\n{\"doc\":{\"foo\":\"bar\"},\"doc_as_upsert\":true}\n{\"delete\":{\"_index\":\"foo\",\"_id\":1,\"routing\":\"bar\"}}\n" end end