implement terms query in evaluator

This commit is contained in:
byte[] 2019-12-20 12:05:28 -05:00
parent ffdddb3f68
commit 04673984f8

View file

@ -68,6 +68,13 @@ defmodule Search.Evaluator do
|> Enum.member?(query_val)
end
def hits?(doc, %{terms: terms_query}) do
[{term, query_vals}] = Enum.to_list(terms_query)
wrap(doc[atomify(term)])
|> Enum.any?(&Enum.member?(query_vals, &1))
end
def hits?(_doc, %{match_all: %{}}), do: true
def hits?(_doc, %{match_none: %{}}), do: false
def hits?(doc, %{function_score: %{query: query}}), do: hits?(doc, query)
@ -139,4 +146,4 @@ defmodule Search.Evaluator do
Regex.compile!("\\A#{re}\\z", "im")
end
end
end