Skip to content

Commit 6d46b98

Browse files
committed
Merge pull request #31 from skurfuerst/master
[FEATURE] allow to configure the full ElasticSearch Mapping via API
2 parents b46c11b + d59d860 commit 6d46b98

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

Classes/Flowpack/ElasticSearch/Domain/Model/Mapping.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* */
1313

1414
use TYPO3\Flow\Annotations as Flow;
15+
use TYPO3\Flow\Utility\Arrays;
1516

1617
/**
1718
* Reflects a Mapping of Elasticsearch
@@ -34,6 +35,15 @@ class Mapping {
3435
*/
3536
protected $dynamicTemplates = array();
3637

38+
/**
39+
* This is the full / raw ElasticSearch mapping which is merged with the properties and dynamicTemplates.
40+
*
41+
* It can be used to specify arbitrary ElasticSearch mapping options, like f.e. configuring the _all field.
42+
*
43+
* @var array
44+
*/
45+
protected $fullMapping = array();
46+
3747
/**
3848
* @param \Flowpack\ElasticSearch\Domain\Model\AbstractType $type
3949
*/
@@ -82,10 +92,10 @@ public function getType() {
8292
* @return array
8393
*/
8494
public function asArray() {
85-
return array($this->type->getName() => array(
95+
return array($this->type->getName() => Arrays::arrayMergeRecursiveOverrule(array(
8696
'dynamic_templates' => $this->getDynamicTemplates(),
8797
'properties' => $this->getProperties()
88-
));
98+
), $this->fullMapping));
8999
}
90100

91101
/**
@@ -116,4 +126,23 @@ public function addDynamicTemplate($dynamicTemplateName, array $mappingConfigura
116126
$dynamicTemplateName => $mappingConfiguration
117127
);
118128
}
129+
130+
/**
131+
* This is the full / raw ElasticSearch mapping which is merged with the properties and dynamicTemplates.
132+
*
133+
* It can be used to specify arbitrary ElasticSearch mapping options, like f.e. configuring the _all field.
134+
*
135+
* @param array $fullMapping
136+
*/
137+
public function setFullMapping(array $fullMapping) {
138+
$this->fullMapping = $fullMapping;
139+
}
140+
141+
/**
142+
* see {@link setFullMapping} for documentation
143+
* @return array
144+
*/
145+
public function getFullMapping() {
146+
return $this->fullMapping;
147+
}
119148
}

0 commit comments

Comments
 (0)