From 29c6dfd57a6d5f50a626d6134a87ab040978a941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Jedenastik?= Date: Tue, 6 Dec 2022 09:07:23 +0100 Subject: [PATCH] BUGFIX: ElasticSearchQueryBuilder removes json encode generated quotes accurately --- Classes/Eel/ElasticSearchQueryBuilder.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Classes/Eel/ElasticSearchQueryBuilder.php b/Classes/Eel/ElasticSearchQueryBuilder.php index 6c9c4917..5114cebc 100644 --- a/Classes/Eel/ElasticSearchQueryBuilder.php +++ b/Classes/Eel/ElasticSearchQueryBuilder.php @@ -684,8 +684,11 @@ public function count(): int */ public function fulltext(string $searchWord, array $options = []): QueryBuilderInterface { + $encodedSearchWord = json_encode($searchWord, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE); + // remove quotes added by json_encode + $encodedSearchWord = \substr($encodedSearchWord, 1, \strlen($encodedSearchWord)-2); // We automatically enable result highlighting when doing fulltext searches. It is up to the user to use this information or not use it. - $this->request->fulltext(trim(json_encode($searchWord, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE), '"'), $options); + $this->request->fulltext($encodedSearchWord, $options); $this->request->highlight(150, 2); return $this;