Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kdambekalns opened this issue Apr 19, 2022 · 0 comments
Open

Comments

@kdambekalns
Copy link
Member

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant