diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Search/QueryContext.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Search/QueryContext.php index ffeb19c924..a53dc9a570 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Search/QueryContext.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Search/QueryContext.php @@ -34,7 +34,7 @@ class QueryContext } } - return new static($this->locales, $this->queryLocale, $fields); + return new static($this->structure, $this->locales, $this->queryLocale, $fields); } public function getRawFields() diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/Search/QueryContextTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/Search/QueryContextTest.php new file mode 100644 index 0000000000..63d9bec908 --- /dev/null +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/Search/QueryContextTest.php @@ -0,0 +1,18 @@ +prophesize(Structure::class)->reveal(); + $available_locales = ['ab', 'cd', 'ef']; + $context = new QueryContext($structure, $available_locales, 'fr'); + $narrowed = $context->narrowToFields(['some_field']); + $this->assertEquals(['some_field'], $narrowed->getFields()); + } +}