mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
implement terms query in evaluator
This commit is contained in:
parent
ffdddb3f68
commit
04673984f8
1 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue