Skip to content

Commit fcd1104

Browse files
committed
[TASK] update README.md
1 parent 70057da commit fcd1104

1 file changed

Lines changed: 76 additions & 26 deletions

File tree

README.md

Lines changed: 76 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,55 @@ main functionalities:
99
* Full-Text Indexing of Pages and other Documents (of course including the full content)
1010

1111

12+
Relevant Packages:
13+
14+
* `TYPO3.TYPO3CR.SearchCommons`: provides common functionality for searching TYPO3CR nodes,
15+
does not contain a search backend
16+
17+
* `Flowpack.ElasticSearch.ContentRepositoryAdaptor`: this package
18+
19+
* `Flowpack.SimpleSearch.ContentRepositoryAdaptor`: an alternative search backend (to be used
20+
instead of this package); storing the search index in SQLite
21+
22+
* `Flowpack.SearchPlugin`: search plugin for Neos
23+
24+
25+
## Version 2 vs Version 1
26+
27+
* Version 1 is the initial, productive version of the Neos ElasticSearch adapter.
28+
* Version 2 has a dependency on TYPO3.TYPO3CR.SearchCommons; which contains base functionality
29+
which is also relevant for other search implementations (like the SQLite based SimpleSearch).
30+
31+
The configuration from Version 1 to Version 2 has changed; here's what to change:
32+
33+
**Settings.yaml**
34+
35+
1. Change the base namespace for configuration from `Flowpack.ElasticSearch.ContentRepositoryAdaptor`
36+
to `TYPO3.TYPO3CR.SearchCommons`. All further adjustments are made underneath this namespace:
37+
38+
2. (If it exists in your configuration:) Move `indexName` to `elasticSearch.indexName`
39+
40+
3. (If it exists in your configuration:) Move `log` to `elasticSearch.log`
41+
42+
4. search for `mapping` (inside `defaultConfigurationPerType.<typeName>`) and replace it by
43+
`elasticSearchMapping`.
44+
45+
5. Inside the `indexing` expressions (at `defaultConfigurationPerType.<typeName>`), replace
46+
`ElasticSearch.` by `Indexing.`.
47+
48+
**NodeTypes.yaml**
49+
50+
1. Replace `elasticSearch` by `search`. This replaces both `<YourNodeType>.elasticSearch`
51+
and `<YourNodeType>.properties.<propertyName>.elasticSearch`.
52+
53+
2. search for `mapping` (inside `<YourNodeType>.properties.<propertyName>.search`) and replace it by
54+
`elasticSearchMapping`.
55+
56+
3. Replace `ElasticSeach.fulltext` by `Indexing`
57+
58+
4. Search for `ElasticSearch.` (inside the `indexing` expressions) and replace them by `Indexing.`
59+
60+
1261
## Building up the Index
1362

1463
The node index is updated on the fly, but during development you need to update it frequently.
@@ -35,20 +84,20 @@ We'll first show how to do arbitrary ElasticSearch Queries in TypoScript. This i
3584
alternative to FlowQuery. In the long run, we might be able to integrate this API back into FlowQuery,
3685
but for now it works well as-is.
3786

38-
Generally, ElasticSearch queries are done using the `ElasticSearch` Eel helper. In case you want
87+
Generally, ElasticSearch queries are done using the `Search` Eel helper. In case you want
3988
to retrieve a *list of nodes*, you'll generally do:
4089
```
41-
nodes = ${ElasticSearch.query(site)....execute()}
90+
nodes = ${Search.query(site)....execute()}
4291
```
4392

4493
In case you just want to retrieve a *single node*, the form of a query is as follows:
4594
```
46-
nodes = ${q(ElasticSearch.query(site)....execute()).get(0)}
95+
nodes = ${q(Search.query(site)....execute()).get(0)}
4796
```
4897

4998
To fetch the total number of hits a query returns, the form of a query is as follows:
5099
```
51-
nodes = ${ElasticSearch.query(site)....count()}
100+
nodes = ${Search.query(site)....count()}
52101
```
53102

54103
All queries search underneath a certain subnode. In case you want to search "globally", you will
@@ -61,6 +110,7 @@ Furthermore, the following operators are supported:
61110
* `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.
62111
* `limit(5)` -- only return five results. If not specified, the default limit by ElasticSearch applies (which is at 10 by default)
63112
* `from(5)` -- return the results starting from the 6th one
113+
* `fulltext(...)` -- do a query_string query on the Fulltext Index
64114

65115
Furthermore, there is a more low-level operator which can be used to add arbitrary ElasticSearch filters:
66116

@@ -91,7 +141,7 @@ prototype(TYPO3.Neos:PrimaryContent).acmeBlogTag {
91141
92142
# The "TagPage"
93143
prototype(Acme.Blog:TagPage) < prototype(TYPO3.TypoScript:Collection) {
94-
collection = ${ElasticSearch.query(site).nodeType('Acme.Blog:Post').exactMatch('tags', node).sortDesc('creationDate').execute()}
144+
collection = ${Search.query(site).nodeType('Acme.Blog:Post').exactMatch('tags', node).sortDesc('creationDate').execute()}
95145
itemName = 'node'
96146
itemRenderer = Acme.Blog:SingleTag
97147
}
@@ -121,36 +171,36 @@ ElasticSearch `_all` field, and are configured with different `boost` values.
121171
In order to search this index, you can just search inside the `_all` field with an additional limitation
122172
of `__typeAndSupertypes` containing `TYPO3.Neos:Document`.
123173

124-
**Currently, this package does not contain a plugin for searching, though we might provide one later on.**
174+
**For a search user interface, checkout the Flowpack.SearchPlugin package**
125175

126176

127177
## Advanced: Configuration of Indexing
128178

129179
**Normally, this does not need to be touched, as this package supports all TYPO3 Neos data types natively.**
130180

131181
Indexing of properties is configured at two places. The defaults per-data-type are configured
132-
inside `Flowpack.ElasticSearch.ContentRepositoryAdaptor.defaultConfigurationPerType` of `Settings.yaml`.
133-
Furthermore, this can be overridden using the `properties.[....].elasticSearch` path inside
182+
inside `TYPO3.TYPO3CR.SearchCommons.defaultConfigurationPerType` of `Settings.yaml`.
183+
Furthermore, this can be overridden using the `properties.[....].search` path inside
134184
`NodeTypes.yaml`.
135185

136186
This configuration contains two parts:
137187

138-
* Underneath `mapping`, the ElasticSearch property mapping can be defined.
188+
* Underneath `elasticSearchMapping`, the ElasticSearch property mapping can be defined.
139189
* Underneath `indexing`, an Eel expression which processes the value before indexing has to be
140190
specified. It has access to the current `value` and the current `node`.
141191

142192
Example (from the default configuration):
143193
```
144194
# Settings.yaml
145-
Flowpack:
146-
ElasticSearch:
147-
ContentRepositoryAdaptor:
195+
TYPO3:
196+
TYPO3CR:
197+
SearchCommons:
148198
defaultConfigurationPerType:
149199
150200
# strings should, by default, not be included in the _all field; and
151201
# indexing should just use their simple value.
152202
string:
153-
mapping:
203+
elasticSearchMapping:
154204
type: string
155205
include_in_all: false
156206
indexing: '${value}'
@@ -161,26 +211,26 @@ Flowpack:
161211
'TYPO3.Neos:Timable':
162212
properties:
163213
'_hiddenBeforeDateTime':
164-
elasticSearch:
214+
search:
165215
166216
# a date should be mapped differently, and in this case we want to use a date format which
167217
# ElasticSearch understands
168-
mapping:
218+
elasticSearchMapping:
169219
type: date
170220
include_in_all: false
171221
format: 'date_time_no_millis'
172222
indexing: '${(node.hiddenBeforeDateTime ? node.hiddenBeforeDateTime.format("Y-m-d\TH:i:s") + "Z" : null)}'
173223
```
174224

175-
There are a few indexing helpers inside the `ElasticSearch` namespace which are usable inside the
225+
There are a few indexing helpers inside the `Indexing` namespace which are usable inside the
176226
`indexing` expression. In most cases, you don't need to touch this, but they were needed to build up
177227
the standard indexing configuration:
178228

179-
* `ElasticSearch.buildAllPathPrefixes`: for a path such as `foo/bar/baz`, builds up a list of path
229+
* `Indexing.buildAllPathPrefixes`: for a path such as `foo/bar/baz`, builds up a list of path
180230
prefixes, e.g. `['foo', 'foo/bar', 'foo/bar/baz']`.
181-
* `ElasticSearch.extractNodeTypeNamesAndSupertypes(NodeType)`: extracts a list of node type names for
231+
* `Indexing.extractNodeTypeNamesAndSupertypes(NodeType)`: extracts a list of node type names for
182232
the passed node type and all of its supertypes
183-
* `ElasticSearch.convertArrayOfNodesToArrayOfNodeIdentifiers(array $nodes)`: convert the given nodes to
233+
* `Indexing.convertArrayOfNodesToArrayOfNodeIdentifiers(array $nodes)`: convert the given nodes to
184234
their node identifiers.
185235

186236

@@ -192,7 +242,7 @@ the following is configured in the default configuration:
192242

193243
```
194244
'TYPO3.Neos:Document':
195-
elasticSearch:
245+
search:
196246
fulltext:
197247
isRoot: true
198248
```
@@ -201,28 +251,28 @@ A *fulltext root* contains all the *content* of its non-document children, such
201251
inside these texts, the document itself is returned as result.
202252

203253
In order to specify how the fulltext of a property in a node should be extracted, this is configured
204-
in `NodeTypes.yaml` at `properties.[propertyName].elasticSearch.fulltextExtractor`.
254+
in `NodeTypes.yaml` at `properties.[propertyName].search.fulltextExtractor`.
205255

206256
An example:
207257

208258
```
209259
'TYPO3.Neos.NodeTypes:Text':
210260
properties:
211261
'text':
212-
elasticSearch:
213-
fulltextExtractor: '${ElasticSearch.fulltext.extractHtmlTags(value)}'
262+
search:
263+
fulltextExtractor: '${Indexing.extractHtmlTags(value)}'
214264
215265
'My.Blog:Post':
216266
properties:
217267
title:
218-
elasticSearch:
219-
fulltextExtractor: ${ElasticSearch.fulltext.extractInto('h1', value)}
268+
search:
269+
fulltextExtractor: ${Indexing.extractInto('h1', value)}
220270
```
221271

222272

223273
## Fulltext Searching / Search Plugin
224274

225-
There is currently no fulltext search plugin included, though we might add one lateron.
275+
**For a search user interface, checkout the Flowpack.SearchPlugin package**
226276

227277

228278
## Debugging

0 commit comments

Comments
 (0)