Skip to content

Commit

Permalink
struct update Hui.U: fix the order of multiple grouped commands so th…
Browse files Browse the repository at this point in the history
…at “commit/optimize” commands take effect (add/delete..then commit)
  • Loading branch information
boonious committed Oct 6, 2018
1 parent dc163d9 commit 4d762ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/hui/u.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ defmodule Hui.U do

def encode(%__MODULE__{} = s) do
a = "#{encode(doc: s.doc, within: s.commitWithin, overwrite: s.overwrite)}"
b = "#{encode(commit: s.commit, wait: s.waitSearcher, expunge: s.expungeDeletes)}"
c = "#{encode(optimize: s.optimize, wait: s.waitSearcher, max: s.maxSegments)}"
d = "#{encode(delete_id: s.delete_id)}"
e = "#{encode(delete_query: s.delete_query)}"
b = "#{encode(delete_id: s.delete_id)}"
c = "#{encode(delete_query: s.delete_query)}"
d = "#{encode(commit: s.commit, wait: s.waitSearcher, expunge: s.expungeDeletes)}"
e = "#{encode(optimize: s.optimize, wait: s.waitSearcher, max: s.maxSegments)}"

x = [a, b, c, d, e] |> Enum.filter(fn x -> x != "" end)
"{#{Enum.join(x, ",")}}"
Expand Down
2 changes: 1 addition & 1 deletion test/data/update_doc10.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"add":{"commitWithin":50,"overwrite":true,"doc":{"name":"Autumn Sonata","initial_release_date":"1978-10-08","id":"tt0077711","genre":["Drama","Music"],"directed_by":["Ingmar Bergman"],"desc":"A married daughter who longs for her mother's love is visited by the latter, a successful concert pianist.","actor_ss":["Ingrid Bergman","Liv Ullmann","Lena Nyman","Halvar Björk"]}},"add":{"commitWithin":50,"overwrite":true,"doc":{"name":"Persona","initial_release_date":"1967-09-21","id":"tt0060827","genre":["Drama","Thriller"],"directed_by":["Ingmar Bergman"],"desc":"A nurse is put in charge of a mute actress and finds that their personas are melding together.","actor_ss":["Bibi Andersson","Liv Ullmann","Margaretha Krook"]}},"commit":{"waitSearcher":true,"expungeDeletes":false},"optimize":{"waitSearcher":true,"maxSegments":20},"delete":{"id":"tt1316540"},"delete":{"id":"tt1650453"}}
{"add":{"commitWithin":50,"overwrite":true,"doc":{"name":"Autumn Sonata","initial_release_date":"1978-10-08","id":"tt0077711","genre":["Drama","Music"],"directed_by":["Ingmar Bergman"],"desc":"A married daughter who longs for her mother's love is visited by the latter, a successful concert pianist.","actor_ss":["Ingrid Bergman","Liv Ullmann","Lena Nyman","Halvar Björk"]}},"add":{"commitWithin":50,"overwrite":true,"doc":{"name":"Persona","initial_release_date":"1967-09-21","id":"tt0060827","genre":["Drama","Thriller"],"directed_by":["Ingmar Bergman"],"desc":"A nurse is put in charge of a mute actress and finds that their personas are melding together.","actor_ss":["Bibi Andersson","Liv Ullmann","Margaretha Krook"]}},"delete":{"id":"tt1316540"},"delete":{"id":"tt1650453"},"commit":{"waitSearcher":true,"expungeDeletes":false},"optimize":{"waitSearcher":true,"maxSegments":20}}

0 comments on commit 4d762ad

Please sign in to comment.