Skip to content

Commit b8a4f9c

Browse files
authored
FEATURE: Allow configuring a prefix for the index name via Settings
With this feature any configured index can get a prefix in ElasticSearch, making it possible to have several contexts indexed into different indexes in the same elastic instance. At the same time index settings are kept centralised and used by the "base" index name.
1 parent 48dc11f commit b8a4f9c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Classes/Domain/Model/Index.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ public function __construct(string $name, Client $client = null)
122122
public function injectSettings(array $settings): void
123123
{
124124
$this->settings = $settings;
125+
$indexSettings = $this->getSettings();
126+
if (!isset($indexSettings['prefix']) || empty($indexSettings['prefix'])) {
127+
return;
128+
}
129+
// This is obviously a side effect but can only be done after injecting settings
130+
// and it needs to be done as early as possible
131+
$this->name = $settings['prefix'] . '-' . $this->name;
125132
}
126133

127134
/**

0 commit comments

Comments
 (0)