mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-01 03:46:44 +01:00
Respect max_clause_count
This commit is contained in:
parent
721432255e
commit
dea3bd913c
1 changed files with 6 additions and 2 deletions
|
@ -29,6 +29,8 @@ defmodule Philomena.Search.Parser do
|
||||||
__data__: nil
|
__data__: nil
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@max_clause_count 512
|
||||||
|
|
||||||
def parser(options) do
|
def parser(options) do
|
||||||
parser = struct(Parser, options)
|
parser = struct(Parser, options)
|
||||||
|
|
||||||
|
@ -305,14 +307,16 @@ defmodule Philomena.Search.Parser do
|
||||||
|
|
||||||
# Flattens the child of a disjunction or conjunction to improve performance.
|
# Flattens the child of a disjunction or conjunction to improve performance.
|
||||||
defp flatten_disjunction_child(this_child, %{bool: %{should: next_child}} = child)
|
defp flatten_disjunction_child(this_child, %{bool: %{should: next_child}} = child)
|
||||||
when child == %{bool: %{should: next_child}} and is_list(next_child),
|
when child == %{bool: %{should: next_child}} and is_list(next_child) and
|
||||||
|
length(next_child) <= @max_clause_count,
|
||||||
do: %{bool: %{should: [this_child | next_child]}}
|
do: %{bool: %{should: [this_child | next_child]}}
|
||||||
|
|
||||||
defp flatten_disjunction_child(this_child, next_child),
|
defp flatten_disjunction_child(this_child, next_child),
|
||||||
do: %{bool: %{should: [this_child, next_child]}}
|
do: %{bool: %{should: [this_child, next_child]}}
|
||||||
|
|
||||||
defp flatten_conjunction_child(this_child, %{bool: %{must: next_child}} = child)
|
defp flatten_conjunction_child(this_child, %{bool: %{must: next_child}} = child)
|
||||||
when child == %{bool: %{must: next_child}} and is_list(next_child),
|
when child == %{bool: %{must: next_child}} and is_list(next_child) and
|
||||||
|
length(next_child) <= @max_clause_count,
|
||||||
do: %{bool: %{must: [this_child | next_child]}}
|
do: %{bool: %{must: [this_child | next_child]}}
|
||||||
|
|
||||||
defp flatten_conjunction_child(this_child, next_child),
|
defp flatten_conjunction_child(this_child, next_child),
|
||||||
|
|
Loading…
Reference in a new issue