@@ -20,8 +20,7 @@ _Currently the Driver interfaces is not marked as API, and can be changed to ada
2020
2121## Relevant Packages
2222
23- * [ Neos.ContentRepository.Search] ( https://www.neos.io/download-and-extend/packages/typo3/typo3-typo3cr-search.html ) : provides common functionality for searching Neos Content Repository nodes,
24- does not contain a search backend
23+ * [ Neos.ContentRepository.Search] ( https://www.neos.io/download-and-extend/packages/neos/neos-content-repository-search.html ) : provides common functionality for searching Neos Content Repository nodes. Does not contain a search backend.
2524* [ Flowpack.ElasticSearch] ( https://www.neos.io/download-and-extend/packages/flowpack/flowpack-elasticsearch.html ) : provides common code for working with Elasticsearch
2625* [ Flowpack.ElasticSearch.ContentRepositoryAdaptor] ( https://www.neos.io/download-and-extend/packages/flowpack/flowpack-elasticsearch-contentrepositoryadaptor.html ) : this package
2726* [ Flowpack.SimpleSearch.ContentRepositoryAdaptor] ( https://www.neos.io/download-and-extend/packages/flowpack/flowpack-simplesearch-contentrepositoryadaptor.html ) : an alternative search backend (to be used instead of this package); storing the search index in SQLite
@@ -34,15 +33,11 @@ composer require 'flowpack/elasticsearch-contentrepositoryadaptor'
3433// Not required, but can be used to learn how to integration the flowpack/elasticsearch-contentrepositoryadaptor in your project
3534composer require 'flowpack/searchplugin'
3635```
36+ Ensure to update ` <your-elasticsearch>/config/elasticsearch.yml ` as explained below; then start Elasticsearch.
3737
38- Now, add the routes as described in the [ README of Flowpack.SearchPlugin] ( https://github.com/Flowpack/Flowpack.SearchPlugin )
39- as the ** first route** in Configuration/Routes.yaml.
38+ Then just run ` ./flow nodeindex:build ` and add the search plugin to your page. It should "just work".
4039
41- Then, ensure to update ` <your-elasticsearch>/config/elasticsearch.yml ` as explained below; then start Elasticsearch.
42-
43- Finally, run ` ./flow nodeindex:build ` , and add the search plugin to your page. It should "just work".
44-
45- ## Elasticsearch Configuration file elasticsearch.yml
40+ ## Elasticsearch Configuration file * elasticsearch.yml*
4641
4742There is a need, depending on your version of Elasticsearch, to add specific configuration to your
4843Elasticsearch Configuration File ` <your-elasticsearch>/config/elasticsearch.yml ` .
@@ -78,24 +73,24 @@ Example is from the Documentation of the used *Flowpack.ElasticSearch* Package
7873
7974https://github.com/Flowpack/Flowpack.ElasticSearch/blob/master/Documentation/Indexer.rst
8075
81- ```
76+ ``` yaml
8277Flowpack :
83- ElasticSearch:
84- indexes:
85- default:
86- ' twitter' :
87- analysis:
88- filter:
89- elision:
90- type: ' elision'
91- articles: [ 'l', 'm', 't', 'qu', 'n', 's', 'j', 'd' ]
92- analyzer:
93- custom_french_analyzer:
94- tokenizer: ' letter'
95- filter: [ 'asciifolding', 'lowercase', 'french_stem', 'elision', 'stop' ]
96- tag_analyzer:
97- tokenizer: ' keyword'
98- filter: [ 'asciifolding', 'lowercase' ]
78+ ElasticSearch :
79+ indexes :
80+ default :
81+ twitter :
82+ analysis :
83+ filter :
84+ elision :
85+ type : elision
86+ articles : [ 'l', 'm', 't', 'qu', 'n', 's', 'j', 'd' ]
87+ analyzer :
88+ custom_french_analyzer :
89+ tokenizer : letter
90+ filter : [ 'asciifolding', 'lowercase', 'french_stem', 'elision', 'stop' ]
91+ tag_analyzer :
92+ tokenizer : keyword
93+ filter : [ 'asciifolding', 'lowercase' ]
9994` ` `
10095
10196If you use multiple client configurations, please change the *default* key just below the *indexes*.
@@ -168,18 +163,18 @@ Fusion setup:
168163` ` `
169164 # for "Tag" documents, replace the main content area.
170165prototype(Neos.Neos:PrimaryContent).acmeBlogTag {
171- condition = ${q(node).is('[instanceof Acme.Blog:Tag]')}
172- type = 'Acme.Blog:TagPage'
166+ condition = ${q(node).is('[instanceof Acme.Blog:Tag]')}
167+ type = 'Acme.Blog:TagPage'
173168}
174169
175170 # The "TagPage"
176171prototype(Acme.Blog:TagPage) < prototype(Neos.Fusion:Collection) {
177- collection = ${Search.query(site).nodeType('Acme.Blog:Post').exactMatch('tags', node).sortDesc('creationDate').execute()}
178- itemName = 'node'
179- itemRenderer = Acme.Blog:SingleTag
172+ collection = ${Search.query(site).nodeType('Acme.Blog:Post').exactMatch('tags', node).sortDesc('creationDate').execute()}
173+ itemName = 'node'
174+ itemRenderer = Acme.Blog:SingleTag
180175}
181176prototype(Acme.Blog:SingleTag) < prototype(Neos.Neos:Template) {
182- ...
177+ ...
183178}
184179` ` `
185180
@@ -189,9 +184,9 @@ There's no OR operator provided in this package, so you need to use a custom Ela
189184
190185` ` `
191186....queryFilter('bool', {should: [
192- {term: {tags: tagNode.identifier}},
193- {term: {places: tagNode.identifier}},
194- {term: {projects: tagNode.identifier}}
187+ {term: {tags: tagNode.identifier}},
188+ {term: {places: tagNode.identifier}},
189+ {term: {projects: tagNode.identifier}}
195190]})
196191` ` `
197192
@@ -228,7 +223,7 @@ Now you can access your aggregations inside your fluid template with
228223#### Create a nested aggregation
229224
230225In this scenario you could have a node that represents a product with the properties price and color. If you would like
231- to know the average price for all your colors you just nest an aggregation in your TypoScript :
226+ to know the average price for all your colors you just nest an aggregation in your Fusion :
232227```
233228nodes = ${Search.query(site)...fieldBasedAggregation("colors", "color").fieldBasedAggregation("avgprice", "price", "avg", "colors").execute()}
234229```
@@ -247,9 +242,9 @@ To add a custom aggregation you can use the `aggregation()` method. All you have
247242aggregation definition. This example would do the same as the fieldBasedAggregation would do for you:
248243```
249244aggregationDefinition = Neos.Fusion: RawArray {
250- terms = Neos.Fusion:RawArray {
251- field = "color"
252- }
245+ terms = Neos.Fusion: RawArray {
246+ field = "color"
247+ }
253248}
254249nodes = ${Search.query(site)...aggregation("color", this.aggregationDefinition).execute()}
255250```
@@ -264,13 +259,13 @@ be a reference on other products.
264259prototype(Vendor.Name: FilteredProductList ) < prototype(Neos.Neos: Content )
265260prototype(Vendor.Name: FilteredProductList ) {
266261
267- // Create SearchFilter for products
268- searchFilter = Neos.Fusion:RawArray {
269- sku = ${String.split(q(node).property("products"), ",")}
270- }
262+ // Create SearchFilter for products
263+ searchFilter = Neos.Fusion:RawArray {
264+ sku = ${String.split(q(node).property("products"), ",")}
265+ }
271266
272- # Search for all products that matches your queryFilter and add aggregations
273- filter = ${Search.query(site).nodeType("Vendor.Name:Product").queryFilterMultiple(this.searchFilter, "must").fieldBasedAggregation("color", "color").fieldBasedAggregation("size", "size").execute()}
267+ # Search for all products that matches your queryFilter and add aggregations
268+ filter = ${Search.query(site).nodeType("Vendor.Name:Product").queryFilterMultiple(this.searchFilter, "must").fieldBasedAggregation("color", "color").fieldBasedAggregation("size", "size").execute()}
274269
275270 # Add more filter if get/post params are set
276271 searchFilter.color = ${request.arguments.color}
@@ -282,13 +277,13 @@ prototype(Vendor.Name:FilteredProductList) {
282277 products = ${Search.query(site).nodeType("Vendor.Name:Product").queryFilterMultiple(this.searchFilter, "must").execute()}
283278
284279 # don't cache this element
285- @cache {
286- mode = 'uncached'
287- context {
288- 1 = 'node'
289- 2 = 'site'
290- }
291- }
280+ @cache {
281+ mode = 'uncached'
282+ context {
283+ 1 = 'node'
284+ 2 = 'site'
285+ }
286+ }
292287```
293288
294289In the first lines we will add a new searchFilter variable and add your selected sku's as a filter. Based on this selection
@@ -370,7 +365,7 @@ First of all you have to define a property in your NodeTypes.yaml for your node
370365 type: "geo_point"
371366```
372367
373- Query your nodes in your TypoScript :
368+ Query your nodes in your Fusion :
374369```
375370geoSorting = Neos.Fusion: RawArray {
376371 _ geo_distance = Neos.Fusion: RawArray {
@@ -389,13 +384,14 @@ nodes = ${Search.query(site).nodeType('Vendor.Name:Retailer').sort(this.geoSorti
389384Now you can paginate that nodes in your template. To get your actually distance for each node use
390385the `GetHitArrayForNodeViewHelper`:
391386```
387+ {namespace cr=Neos\ContentRepository\ViewHelpers}
392388{namespace es=Flowpack\ElasticSearch\ContentRepositoryAdaptor\ViewHelpers}
393389
394- <typo3cr :widget.paginate query="{nodes}" as="paginatedNodes">
390+ <cr : widget .paginate query="{nodes}" as="paginatedNodes">
395391 <f: for each="{paginatedNodes}" as="singleNode">
396392 {singleNode.name} - <es: getHitArrayForNode queryResultObject="{nodes}" node="{singleNode}" path="sort.0" />
397393 </f: for >
398- </typo3cr :widget.paginate>
394+ </cr : widget .paginate>
399395
400396```
401397
0 commit comments