boost values must be non-negative since ES7 (bm25 forbids negative scores)

This commit is contained in:
byte[] 2021-03-18 01:29:21 -04:00
parent 8c881da01c
commit ba900f4ad6

View file

@ -107,9 +107,12 @@ defmodule Philomena.Search.Parser do
defp search_boost(parser, tokens) do
case search_not(parser, tokens) do
{:ok, {child, [{:boost, value} | r_tokens]}} ->
{:ok, {child, [{:boost, value} | r_tokens]}} when value >= 0 ->
{:ok, {%{function_score: %{query: child, boost: value}}, r_tokens}}
{:ok, {_child, [{:boost, _value} | _r_tokens]}} ->
{:error, "Boost value must be non-negative."}
value ->
value
end