@@ -212,7 +212,8 @@ Furthermore, the following operators are supported:
212212* ` greaterThanOrEqual('propertyName', value) ` -- range filter with property values greater than or equal to the given value
213213* ` lessThan('propertyName', value) ` -- range filter with property values less than the given value
214214* ` lessThanOrEqual('propertyName', value) ` -- range filter with property values less than or equal to the given value
215- * ` sortAsc('propertyName') ` and ` sortDesc('propertyName') ` -- can also be used multiple times, e.g. ` sortAsc('tag').sortDesc( ` date')` will first sort by tag ascending, and then by date descending.
215+ * ` sortAsc('propertyName') ` and ` sortDesc('propertyName') ` -- can also be used multiple times, e.g. ` sortAsc('tag').sortDesc( ` date')`
216+ will first sort by tag ascending, and then by date descending.
216217* ` limit(5) ` -- only return five results. If not specified, the default limit by Elasticsearch applies (which is at 10 by default)
217218* ` from(5) ` -- return the results starting from the 6th one
218219* ` fulltext(...) ` -- do a query_string query on the Fulltext Index
@@ -255,6 +256,18 @@ prototype(Acme.Blog:SingleTag) < prototype(TYPO3.Neos:Template) {
255256}
256257```
257258
259+ #### Making OR queries
260+
261+ There's no OR operator provided in this package, so you need to use a custom Elasticsearch query filter for that:
262+
263+ ```
264+ ....queryFilter('bool', {should: [
265+ {term: {tags: tagNode.identifier}},
266+ {term: {places: tagNode.identifier}},
267+ {term: {projects: tagNode.identifier}}
268+ ]})
269+ ```
270+
258271## Aggregations
259272
260273Aggregation is an easy way to aggregate your node data in different ways. Elasticsearch provides a couple of different types of
@@ -272,7 +285,9 @@ You can nest aggregations by providing a parent name.
272285
273286
274287### Examples
288+
275289#### Add a average aggregation
290+
276291To add an average aggregation you can use the fieldBasedAggregation. This snippet would add an average aggregation for
277292a property price:
278293```
@@ -284,6 +299,7 @@ Now you can access your aggregations inside your fluid template with
284299```
285300
286301#### Create a nested aggregation
302+
287303In this scenario you could have a node that represents a product with the properties price and color. If you would like
288304to know the average price for all your colors you just nest an aggregation in your TypoScript:
289305```
@@ -299,6 +315,7 @@ fieldBasedAggregation("anotherAggregation", "field", "avg", "colors.avgprice")
299315```
300316
301317#### Add a custom aggregation
318+
302319To add a custom aggregation you can use the ` aggregation() ` method. All you have to do is to provide an array with your
303320aggregation definition. This example would do the same as the fieldBasedAggregation would do for you:
304321```
@@ -311,6 +328,7 @@ nodes = ${Search.query(site)...aggregation("color", this.aggregationDefinition).
311328```
312329
313330#### Product filter
331+
314332This is a more complex scenario. With this snippet we will create a full product filter based on your selected Nodes. Imagine
315333an NodeTye ProductList with an property ` products ` . This property contains a comma separated list of sku's. This could also
316334be a reference on other products.
@@ -356,8 +374,8 @@ be fetched and passed to your template.
356374
357375** Important notice**
358376
359- If you do use the terms filter be aware of Elasticsearchs analyze functionality. You might want to disable this for all
360- your filterable properties like this :
377+ If you do use the terms filter be aware of Elasticsearchs analyze functionality for strings . You might want to disable this
378+ for all your filterable properties, or else filtering won't work on them properly :
361379```
362380'Vendor.Name:Product'
363381 properties:
@@ -373,7 +391,7 @@ your filterable properties like this:
373391
374392## Sorting
375393
376- This package adapts ElasticSearchs sorting capabilities. You can add multiple sort operations to your query.
394+ This package adapts Elasticsearchs sorting capabilities. You can add multiple sort operations to your query.
377395Right now there are three methods you can use:
378396
379397* ` sortAsc('propertyName') `
@@ -382,13 +400,16 @@ Right now there are three methods you can use:
382400
383401Just append those method to your query like this:
384402```
385- # sort ascending by property title
403+ # Sort ascending by property title
404+
386405nodes = ${q(Search.query(site).....sortAsc("title").execute())}
387406
388- # sort for multiple properties
407+ # Sort for multiple properties
408+
389409nodes = ${q(Search.query(site).....sortAsc("title").sortDesc("name").execute())}
390410
391- # custom sort opertation
411+ # Custom sort operation
412+
392413geoSorting = TYPO3.TypoScript:RawArray {
393414 _geo_distance = TYPO3.TypoScript:RawArray {
394415 latlng = TYPO3.TypoScript:RawArray {
@@ -407,6 +428,7 @@ Check https://www.elastic.co/guide/en/elasticsearch/reference/current/search-req
407428options.
408429
409430### Example with pagination and sort by distance
431+
410432This is how a more complex example could look like. Imagine you a want to render a list of nodes and in addition to each
411433node you want to display the distance to a specific point.
412434
@@ -454,6 +476,7 @@ The ViewHelper will use \TYPO3\Flow\Utility\Arrays::getValueByPath() to return a
454476of an array or a string. Check the documentation \TYPO3\Flow\Utility\Arrays::getValueByPath() for more informations.
455477
456478** Important notice**
479+
457480The ViewHelper GetHitArrayForNode will return the raw hit result array. The path poperty allows you to access some
458481specific data like the the sort data. If there is only one value for your path the value will be returned.
459482If there is more data the full array will be returned by GetHitArrayForNode-VH. So you might have to use the
@@ -489,26 +512,30 @@ Elasticsearch offers an easy way to get query suggestions based on your query. C
489512you can build and use suggestion in your search.
490513
491514** Suggestion methods implemented**
492- There are two methods implemented. ` suggestions ` is a generic one that allows to build the suggestion query of your
493- dreams. The other method is ` termSuggestions ` and is meant for basic term suggestions. They can be added to your totaly
515+
516+ There are two methods implemented. ` suggestions ` is a generic one that allows to build the suggestion query of your
517+ dreams. The other method is ` termSuggestions ` and is meant for basic term suggestions. They can be added to your totaly
494518awesome TS search query.
495-
519+
496520* ` suggestions($name, array $suggestionDefinition) ` -- generic method to be filled with your own suggestionQuery
497521* ` termSuggestions($term, $field = '_all', $name = 'suggestions' ` -- simple term suggestion query on all fields
498522
499523### Examples
524+
500525#### Add a simple suggestion to a query
526+
501527Simple suggestion that returns a suggestion based on the sent term
502528
503529```
504530suggestions = $(Search.query(site)...termSuggestions('someTerm')}
505531```
506- You can access your suggestions inside your fluid template with
532+ You can access your suggestions inside your fluid template with
507533```
508534{nodes.suggestions}
509535```
510536
511537### Add a custom suggestion
538+
512539Phrase query that returns query suggestions
513540
514541```
@@ -529,7 +556,8 @@ suggestions = ${Search.query(site)...suggestions('my_suggestions', this.suggesti
529556
530557## Advanced: Configuration of Indexing
531558
532- ** Normally, this does not need to be touched, as this package supports all Neos data types natively.**
559+ ** The default configuration supports most usecases and often may not need to be touched, as this package comes
560+ with sane defaults for all Neos data types.**
533561
534562Indexing of properties is configured at two places. The defaults per-data-type are configured
535563inside ` TYPO3.TYPO3CR.Search.defaultConfigurationPerType ` of ` Settings.yaml ` .
@@ -575,6 +603,9 @@ TYPO3:
575603 indexing: '${(node.hiddenBeforeDateTime ? Date.format(node.hiddenBeforeDateTime, "Y-m-d\TH:i:sP") : null)}'
576604```
577605
606+ If your nodetypes schema defines custom properties of type DateTime, you have got to provide similar configuration for
607+ them as well in your ` NodeTypes.yaml ` , or else they will not be indexed correctly.
608+
578609There are a few indexing helpers inside the ` Indexing ` namespace which are usable inside the
579610` indexing ` expression. In most cases, you don't need to touch this, but they were needed to build up
580611the standard indexing configuration:
@@ -647,6 +678,12 @@ currently configured in PHP, the configuration for any property in a node which
647678This is important so that Date- and Time-based searches work as expected, both when using formatted DateTime strings and
648679when using relative DateTime calculations (eg.: ` now ` , ` now+1d ` ).
649680
681+ If you want to filter items by date, e.g. to show items with date later than today, you can create a query like this:
682+
683+ ```
684+ ${...greaterThan('date', Date.format(Date.Now(), "Y-m-d\TH:i:sP"))...}
685+ ```
686+
650687For more information on Elasticsearch's Date Formats,
651688[ click here] ( http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html ) .
652689
0 commit comments