Skip to content

Instantly share code, notes, and snippets.

@knewter
Last active August 29, 2015 14:03
Show Gist options
  • Save knewter/df4a651543c7587641f2 to your computer and use it in GitHub Desktop.
Save knewter/df4a651543c7587641f2 to your computer and use it in GitHub Desktop.
1) test sorts by the number of fields present in the doc (FindGoodSolrDocTest)
test/find_good_solr_doc_test.exs:24
** (FunctionClauseError) no function clause matching in Enumerable.Function.reduce/3
stacktrace:
(elixir) lib/enum.ex:2198: Enumerable.Function.reduce(#Function<0.18085451/1 in FindGoodSolrDocTest.test sorts by the number of fields present in the doc/1>, {:cont, []}, #Function<32.13715154/2 in Enum.reduce/3>)
(elixir) lib/enum.ex:1256: Enum.reduce/3
(elixir) lib/enum.ex:1545: Enum.sort/2
test/find_good_solr_doc_test.exs:27
test "sorts by the number of fields present in the doc" do
output = @docs
|> Enum.map &({&1["id"], (Map.keys(&1) |> Enum.count)})
|> Enum.sort(fn({_, a}, {_, b}) -> a > b end)
IO.inspect output
end
test "sorts by the number of fields present in the doc" do
list = @docs
|> Enum.map &({&1["id"], (Map.keys(&1) |> Enum.count)})
output = Enum.sort(list, fn({_, a}, {_, b}) -> a > b end)
IO.inspect output
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment