You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FEATURE: Support .simpleQueryStringFulltext() simple query string query for fulltext search
We want to support phrase searches like `"Neos and Flow"`, where
quotes mean "I want this exact phrase" (similar to many search engines).
When using the .fulltext() query, this did not work, and we sometimes
encountered crashes when the query string contained quotes, f.e. `"Hallo"`
or `Ha"llo"`.
This is because the .fulltext() query does some magic for supporting UTF8
(as it seems), namely: `trim(json_encode($searchWord, JSON_UNESCAPED_UNICODE), '"')`.
This removes some quotes, but not all of them :-)
The simple_query_string query of Elasticsearch exposes a query string syntax
which the user is directly allowed to enter:
> While its syntax is more limited than the query_string query, the simple_query_string
> query does not return errors for invalid syntax. Instead, it ignores any invalid
> parts of the query string.
This is exactly what we want for a good search field behavior.
NOTE: We created an additional method because we were unsure about breaking
backwards compatibility; but we think `simpleQueryStringFulltext()` should
be used almost universally as replacement for `fulltext()`, as it returns
better results and does not throw exceptions..
* Match the searchword against the fulltext index.
670
+
*
671
+
* NOTE: Please use {@see simpleQueryStringFulltext} instead, as it is more robust.
672
672
*
673
673
* @param string $searchWord
674
674
* @param array $options Options to configure the query_string, see https://www.elastic.co/guide/en/elasticsearch/reference/7.6/query-dsl-query-string-query.html
@@ -684,6 +684,32 @@ public function fulltext(string $searchWord, array $options = []): QueryBuilderI
684
684
return$this;
685
685
}
686
686
687
+
/**
688
+
* Match the searchword against the fulltext index using the elasticsearch
* This method has two main benefits over {@see fulltext()}:
692
+
* - Supports phrase searches like `"Neos and Flow"`, where
693
+
* quotes mean "I want this exact phrase" (similar to many search engines).
694
+
* - do not crash if the user does not enter a fully syntactically valid query
695
+
* (invalid query parts are ignored).
696
+
*
697
+
* This is exactly what we want for a good search field behavior.
698
+
*
699
+
* @param string $searchWord
700
+
* @param array $options Options to configure the query_string, see https://www.elastic.co/guide/en/elasticsearch/reference/7.6/query-dsl-query-string-query.html
0 commit comments