summaryrefslogtreecommitdiff
path: root/src/engine/VyOSElasticModernFulltextStorageEngine.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/VyOSElasticModernFulltextStorageEngine.php')
-rw-r--r--src/engine/VyOSElasticModernFulltextStorageEngine.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/engine/VyOSElasticModernFulltextStorageEngine.php b/src/engine/VyOSElasticModernFulltextStorageEngine.php
index 16c519c..f798e4b 100644
--- a/src/engine/VyOSElasticModernFulltextStorageEngine.php
+++ b/src/engine/VyOSElasticModernFulltextStorageEngine.php
@@ -51,6 +51,23 @@ abstract class VyOSElasticModernFulltextStorageEngine
public function buildIndexMappings(
array $doc_types, array $fields, array $relationships, $text_type) {
+ // These are emitted as fixed standard fields at the end of the mapping.
+ // Caller-supplied $fields or $relationships must not shadow them.
+ static $reserved = array('documentType', 'dateCreated', 'lastModified');
+
+ $all_caller_keys = array_merge(
+ $fields,
+ $relationships,
+ array_map(function($r) { return $r.'_ts'; }, $relationships));
+ $collisions = array_intersect($all_caller_keys, $reserved);
+ if ($collisions) {
+ throw new Exception(
+ pht(
+ 'buildIndexMappings(): caller-supplied field(s) "%s" collide with '.
+ 'reserved mapping keys.',
+ implode('", "', array_values($collisions))));
+ }
+
$properties = array();
foreach ($fields as $field) {