From 04673984f8edaff49e4b7194a53b192d99285e86 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Fri, 20 Dec 2019 12:05:28 -0500 Subject: [PATCH] implement terms query in evaluator --- lib/search/evaluator.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/search/evaluator.ex b/lib/search/evaluator.ex index cb3f2ab7..5fabc406 100644 --- a/lib/search/evaluator.ex +++ b/lib/search/evaluator.ex @@ -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 \ No newline at end of file +end