From fc6d0694c3ea30109e07050a8714f1ab4ad999da Mon Sep 17 00:00:00 2001 From: Anvit Srivastav Date: Thu, 21 Nov 2024 17:35:20 -0800 Subject: [PATCH] Remove ES index prefix from MultiIndexWrapper Remove the index prefix from arElasticSearchMultiIndexWrapper and use AtoM class names internally instead of using prefix to refer to them. --- ...arElasticSearchMultiIndexWrapper.class.php | 24 ++++--------------- .../lib/arElasticSearchPlugin.class.php | 7 +++--- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/plugins/arElasticSearchPlugin/lib/arElasticSearchMultiIndexWrapper.class.php b/plugins/arElasticSearchPlugin/lib/arElasticSearchMultiIndexWrapper.class.php index 6eaddbd057..8b7b4d850a 100644 --- a/plugins/arElasticSearchPlugin/lib/arElasticSearchMultiIndexWrapper.class.php +++ b/plugins/arElasticSearchPlugin/lib/arElasticSearchMultiIndexWrapper.class.php @@ -18,35 +18,25 @@ */ /** - * arElasticSearchMultiIndexWrapper facilitates handling ElasticSearch indices so that - * all indices for an AtoM installation can share a common prefix without having to - * explicitly specify it in common indexing and search functions. + * arElasticSearchMultiIndexWrapper facilitates handling ElasticSearch indices + * and has methods that match signatures of pre ES 6.x methods that used a + * single index with multiple types instead of multiple index with a single + * type or no type. */ class arElasticSearchMultiIndexWrapper { protected $indices; - protected $indexPrefix; - - public function __construct($prefix) + public function __construct() { $this->indices = []; - - $this->indexPrefix = $prefix; } public function addIndex($name, Elastica\Index $index) { - $name = $this->getIndexName($name); $this->indices[$name] = $index; } - // Converts camelized Qubit class names to lower case index name used for ElasticSearch - public function getIndexName($name) - { - return $this->indexPrefix.'_'.strtolower($name); - } - public function delete() { foreach ($this->indices as $index) { @@ -56,13 +46,11 @@ public function delete() public function addDocuments($name, $documents) { - $name = $this->getIndexName($name); $this->indices[$name]->addDocuments($documents); } public function deleteDocuments($name, $documents) { - $name = $this->getIndexName($name); $this->indices[$name]->deleteDocuments($documents); } @@ -77,8 +65,6 @@ public function refresh() // that matches the qualified index name public function getIndex($name) { - $name = $this->getIndexName($name); - return $this->indices[$name]; } diff --git a/plugins/arElasticSearchPlugin/lib/arElasticSearchPlugin.class.php b/plugins/arElasticSearchPlugin/lib/arElasticSearchPlugin.class.php index 2d1e41d9ec..ce374f6f01 100644 --- a/plugins/arElasticSearchPlugin/lib/arElasticSearchPlugin.class.php +++ b/plugins/arElasticSearchPlugin/lib/arElasticSearchPlugin.class.php @@ -105,7 +105,7 @@ public function __construct(array $options = []) // Verify the version running in the server $this->checkVersion(); - $this->index = new arElasticSearchMultiIndexWrapper($this->config['index']['name']); + $this->index = new arElasticSearchMultiIndexWrapper(); // Load batch mode configuration $this->batchMode = true === $this->config['batch_mode']; @@ -547,8 +547,9 @@ protected function initialize() // Iterate over types (actor, informationobject, ...) foreach ($this->mappings as $indexName => $indexProperties) { $indexName = 'Qubit'.sfInflector::camelize($indexName); + $prefixedIndexName = $this->config['index']['name'].'_'.strtolower($indexName); $this->index->addIndex($indexName, - $this->client->getIndex($this->index->getIndexName($indexName)) + $this->client->getIndex($prefixedIndexName) ); } @@ -592,7 +593,7 @@ protected function initialize() foreach ($this->mappings as $indexName => $indexProperties) { $indexName = 'Qubit'.sfInflector::camelize($indexName); - if ($indexType != $this->index->getIndexName($indexName)) { + if ($indexType != $indexName) { continue; }