Skip to content

"test" gets escaped and then trimmed to \"test\ which leads to an error #393

@kdambekalns

Description

@kdambekalns

If searched for "test" it gets escaped and then trimmed to \"test\ which leads to an error:

[type] => query_shard_exception
                            [reason] => Failed to parse query [\"test\]
                            [caused_by] => Array
                                (
                                    [type] => parse_exception
                                    [reason] => Cannot parse '\"test\': Lexical error at line 1, column 17.  Encountered: <EOF> after : ""
                                    [caused_by] => Array
                                        (
                                            [type] => token_mgr_error
                                            [reason] => Lexical error at line 1, column 17.  Encountered: <EOF> after : ""
                                        )

                                )

It can be patched with:

Index: Classes/Eel/ElasticSearchQueryBuilder.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Classes/Eel/ElasticSearchQueryBuilder.php b/Classes/Eel/ElasticSearchQueryBuilder.php
--- a/Classes/Eel/ElasticSearchQueryBuilder.php	
+++ b/Classes/Eel/ElasticSearchQueryBuilder.php	(date 1649436183235)
@@ -678,7 +678,7 @@
     public function fulltext(string $searchWord, array $options = []): QueryBuilderInterface
     {
         // 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_UNESCAPED_UNICODE), '"'), $options);
+        $this->request->fulltext(trim(json_encode($searchWord, JSON_UNESCAPED_UNICODE), '\\"'), $options);
         $this->request->highlight(150, 2);
 
         return $this;

Originally posted by @fdsis in #228 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions