@@ -53,8 +53,6 @@ public function buildMappingInformation(Index $index)
5353
5454 $ mappings = new MappingCollection (MappingCollection::TYPE_ENTITY );
5555
56- $ this ->setupStoredScripts ($ index );
57-
5856 /** @var NodeType $nodeType */
5957 foreach ($ this ->nodeTypeManager ->getNodeTypes () as $ nodeTypeName => $ nodeType ) {
6058 if ($ nodeTypeName === 'unstructured ' || $ nodeType ->isAbstract ()) {
@@ -104,67 +102,6 @@ public function buildMappingInformation(Index $index)
104102 return $ mappings ;
105103 }
106104
107- /**
108- * Store scripts used during indexing in Elasticsearch.
109- *
110- * @param Index $index
111- * @return void
112- */
113- protected function setupStoredScripts (Index $ index )
114- {
115- $ this ->client ->request (
116- 'POST ' ,
117- '/_scripts/updateFulltextParts ' ,
118- [],
119- json_encode (['script ' => [
120- 'lang ' => 'painless ' ,
121- 'code ' => '
122- HashMap fulltext = (ctx._source.containsKey("__fulltext") ? ctx._source.__fulltext : new HashMap());
123- HashMap fulltextParts = (ctx._source.containsKey("__fulltextParts") ? ctx._source.__fulltextParts : new HashMap());
124- ctx._source = params.newData;
125- ctx._source.__fulltext = fulltext;
126- ctx._source.__fulltextParts = fulltextParts '
127- ]
128- ])
129- );
130-
131- $ this ->client ->request (
132- 'POST ' ,
133- '/_scripts/regenerateFulltext ' ,
134- [],
135- json_encode (['script ' => [
136- 'lang ' => 'painless ' ,
137- 'code ' => '
138- ctx._source.__fulltext = new HashMap();
139- if (!ctx._source.containsKey("__fulltextParts")) {
140- ctx._source.__fulltextParts = new HashMap();
141- }
142-
143- if (params.nodeIsRemoved || params.nodeIsHidden || params.fulltext.size() == 0) {
144- if (ctx._source.__fulltextParts.containsKey(params.identifier)) {
145- ctx._source.__fulltextParts.remove(params.identifier);
146- }
147- } else {
148- ctx._source.__fulltextParts.put(params.identifier, params.fulltext);
149- }
150-
151- ctx._source.__fulltextParts.each {
152- originNodeIdentifier, partContent -> partContent.each {
153- bucketKey, content ->
154- if (ctx._source.__fulltext.containsKey(bucketKey)) {
155- value = ctx._source.__fulltext[bucketKey] + " " + content.trim();
156- } else {
157- value = content.trim();
158- }
159- ctx._source.__fulltext[bucketKey] = value;
160- }
161- }
162- '
163- ]
164- ])
165- );
166- }
167-
168105 /**
169106 * Adjust the mapping for string to text or keyword as needed.
170107 *
0 commit comments