Skip to content

Commit fa2af41

Browse files
committed
[TASK] transform fulltext scripting from mvel to groovy
Unfortunately you must now add the two lines of Configuration which are mentioned in the README to the elasticsearch.yaml The default param of script.disable_dynamic is sandbox, so the used class and methods in the script part must be whitelisted
1 parent 5f56d45 commit fa2af41

2 files changed

Lines changed: 48 additions & 5 deletions

File tree

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Indexer/NodeIndexer.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ public function indexNode(Node $node, $targetWorkspaceName = NULL) {
193193
'params' => array(
194194
'newData' => $documentData
195195
),
196-
'upsert' => $documentData
196+
'upsert' => $documentData,
197+
'lang' => 'groovy'
198+
199+
197200
)
198201
);
199202
} else {
@@ -256,10 +259,15 @@ protected function updateFulltext(Node $node, array $fulltextIndexOfNode, $targe
256259
ctx._source.__fulltextParts = new LinkedHashMap();
257260
}
258261
ctx._source.__fulltextParts[identifier] = fulltext;
259-
260262
ctx._source.__fulltext = new LinkedHashMap();
261-
foreach (fulltextByNode : ctx._source.__fulltextParts.entrySet()) {
262-
foreach (element : fulltextByNode.value.entrySet()) {
263+
264+
Iterator fulltextByNode = ctx._source.__fulltextParts.iterator();
265+
for (fulltextByNode; fulltextByNode.hasNext();) {
266+
267+
Iterator elementIterator = fulltextByNode.next().iterator();
268+
for (elementIterator; elementIterator.hasNext();) {
269+
270+
Map.Entry<String, String> element = elementIterator.next();
263271
if (ctx._source.__fulltext.containsKey(element.key)) {
264272
ctx._source.__fulltext[element.key] += " " + element.value;
265273
} else {
@@ -277,7 +285,8 @@ protected function updateFulltext(Node $node, array $fulltextIndexOfNode, $targe
277285
'__fulltextParts' => array(
278286
$node->getIdentifier() => $fulltextIndexOfNode
279287
)
280-
)
288+
),
289+
'lang' => 'groovy'
281290
)
282291
);
283292
}

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,40 @@ Relevant Packages:
3030

3131
The configuration from Version 1 to Version 2 has changed; here's what to change:
3232

33+
**elasticsearch.yaml**
34+
35+
Due to the fact that the default scripting language has changed from marvel to groovy since elasticsearch 1.3.0,
36+
there is a need, depending on your running installation of ElasticSearch, to add following lines of configuration to your
37+
ElasticSearch Configuration File `elasticsearch.yaml`.
38+
39+
If you are using ElasticSearch version 1.2 you have also to install groovy as a plugin. To install the plugin just run
40+
the following command in the root folder of your elastic:
41+
42+
```
43+
bin/plugin -install elasticsearch/elasticsearch-lang-groovy/2.2.0.
44+
```
45+
46+
```
47+
script.disable_dynamic: false
48+
script.default_lang: groovy
49+
50+
```
51+
52+
For running with version > 1.3.x, what is recommended, it is sufficient to add following lines to your
53+
`elasticsearch.yaml`.
54+
55+
56+
```
57+
script.groovy.sandbox.class_whitelist: java.util.LinkedHashMap
58+
script.groovy.sandbox.receiver_whitelist: java.util.Iterator, java.lang.Object, java.util.Map, java.util.Map$Entry
59+
```
60+
61+
You can get further information about this topic here:
62+
63+
http://www.elasticsearch.org/blog/elasticsearch-1-3-0-released/
64+
http://www.elasticsearch.org/blog/scripting-security/
65+
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html
66+
3367
**Settings.yaml**
3468

3569
1. Change the base namespace for configuration from `Flowpack.ElasticSearch.ContentRepositoryAdaptor`

0 commit comments

Comments
 (0)