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
Copy file name to clipboardExpand all lines: Classes/Eel/ElasticSearchQueryBuilder.php
+29-1Lines changed: 29 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -672,7 +672,9 @@ public function count(): int
672
672
}
673
673
674
674
/**
675
-
* Match the searchword against the fulltext index
675
+
* Match the searchword against the fulltext index.
676
+
*
677
+
* NOTE: Please use {@see simpleQueryStringFulltext} instead, as it is more robust.
676
678
*
677
679
* @param string $searchWord
678
680
* @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
@@ -689,6 +691,32 @@ public function fulltext(string $searchWord, array $options = []): QueryBuilderI
689
691
return$this;
690
692
}
691
693
694
+
/**
695
+
* Match the searchword against the fulltext index using the elasticsearch
* This method has two main benefits over {@see fulltext()}:
699
+
* - Supports phrase searches like `"Neos and Flow"`, where
700
+
* quotes mean "I want this exact phrase" (similar to many search engines).
701
+
* - do not crash if the user does not enter a fully syntactically valid query
702
+
* (invalid query parts are ignored).
703
+
*
704
+
* This is exactly what we want for a good search field behavior.
705
+
*
706
+
* @param string $searchWord
707
+
* @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
Copy file name to clipboardExpand all lines: README.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -441,18 +441,19 @@ As **value**, the following methods accept a simple type, a node object or a Dat
441
441
|`from(5)` |Return the results starting from the 6th one|
442
442
|`prefix('propertyName', 'prefix', [clauseType])` |Adds a prefix filter on the given field with the given prefix|
443
443
|`geoDistance(propertyName, geoPoint, distance, [clauseType])`. |Filters documents that include only hits that exists within a specific distance from a geo point.|
444
-
|`fulltext('searchWord', options)` |Does a query_string query on the Fulltext index using the searchword and additional [options](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/query-dsl-query-string-query.html) to the query_string|
444
+
|`fulltext('searchWord', options)` |Does a query_string query on the Fulltext index using the searchword and additional [options](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/query-dsl-query-string-query.html) to the query_string. Recommendation: **use simpleQueryStringFulltext instead, as it yields better results and is more tolerant to user input**.|
445
+
|`simpleQueryStringFulltext('searchWord', options)` |Does a simple_query_string query on the Fulltext index using the searchword and additional [options](https://www.elastic.co/guide/en/elasticsearch/reference/8.3/query-dsl-simple-query-string-query.html) to the simple_query_string. Supports phrase matching like `"firstname lastname"` and tolerates broken input without exceptions (in contrast to `fulltext()`)|
445
446
|`highlight(fragmentSize, fragmentCount, noMatchSize, field)` |Configure result highlighting for every fulltext field individually|
446
447
447
448
## Search Result Highlighting
448
449
449
-
When using the `.fulltext()` oprtator to do a fulltext, **highlight snippets** ([elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/highlighting.html#highlighting)) are automatically queried. By default snippets with 150 characters are queried for all available fulltext fields with a 150 character fallback text.
450
+
When using the `.fulltext()` or `.simpleQueryStringFulltext()` operator to do a fulltext, **highlight snippets** ([elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/highlighting.html#highlighting)) are automatically queried. By default snippets with 150 characters are queried for all available fulltext fields with a 150 character fallback text.
450
451
451
452
To adjust this behavior you can first deactivate the default and then configure highlighting for every field individually:
This deactivates the default highlighting and then queries 2 snipets of 150 characters each from hits in `neos_fulltext.text`, with a fallback to 150 charchters of the beginning of the text if no match was found and additional 100 characters from `neos_fulltext.h2` without a fallback.
456
+
This deactivates the default highlighting and then queries 2 snipets of 150 characters each from hits in `neos_fulltext.text`, with a fallback to 150 characters of the beginning of the text if no match was found and additional 100 characters from `neos_fulltext.h2` without a fallback.
0 commit comments