From 56f212587d5e1a4f7f4874c3112246edf4e96acb Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Fri, 9 Aug 2024 10:19:30 +1000 Subject: [PATCH] Apply patch for bulk delete, remove destination --- composer.json | 3 +- .../TideElasticSearchDestination.php | 85 ------------------- 2 files changed, 2 insertions(+), 86 deletions(-) delete mode 100644 modules/tide_data_pipeline/src/Plugin/DatasetDestination/TideElasticSearchDestination.php diff --git a/composer.json b/composer.json index e2a3ab2..47ac640 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ }, "drupal/data_pipelines": { "CSV data header row whitespace needs to be cleaned up - https://drupal.org/project/data_pipelines/issues/3391214": "https://www.drupal.org/files/issues/2023-10-03/trim-whitespace-from-csv-header-names-3391214-2.patch", - "set a default value based on certain criteria - https://www.drupal.org/project/data_pipelines/issues/3426248#comment-15507258": "https://www.drupal.org/files/issues/2024-03-21/data_pipelines-3426248-6.patch.patch" + "set a default value based on certain criteria - https://www.drupal.org/project/data_pipelines/issues/3426248#comment-15507258": "https://www.drupal.org/files/issues/2024-03-21/data_pipelines-3426248-6.patch.patch", + "Complete the fix for bulk indexing on Elasticsearch endpoint - https://www.drupal.org/project/data_pipelines/issues/3467021#comment-15720597": "https://www.drupal.org/files/issues/2024-08-09/Change-bulk-deleting-on-Elasticsearch-endpoint-3467021.patch" } }, "drush": { diff --git a/modules/tide_data_pipeline/src/Plugin/DatasetDestination/TideElasticSearchDestination.php b/modules/tide_data_pipeline/src/Plugin/DatasetDestination/TideElasticSearchDestination.php deleted file mode 100644 index c9df569..0000000 --- a/modules/tide_data_pipeline/src/Plugin/DatasetDestination/TideElasticSearchDestination.php +++ /dev/null @@ -1,85 +0,0 @@ - '', - ] + parent::defaultConfiguration(); - } - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state): array { - $form = parent::buildConfigurationForm($form, $form_state); - $form['hash_prefix'] = [ - '#type' => 'textfield', - '#title' => $this->t('Index Hash Prefix'), - '#description' => $this->t('The index hash prefix to use.'), - '#default_value' => $this->configuration['hash_prefix'], - ]; - return $form; - } - - /** - * {@inheritdoc} - */ - public function processCleanup(DatasetInterface $dataset, array $invalidDeltas): bool { - $full_index_id = $this->getFullIndexId($dataset->getMachineName()); - try { - $bulk = ['body' => []]; - foreach ($invalidDeltas as $delta) { - $bulk['body'][] = [ - 'delete' => [ - '_index' => $full_index_id, - '_id' => $dataset->getMachineName() . ':' . $delta, - ], - ]; - } - if (count($bulk['body']) > 0) { - $this->getClient()->bulk($bulk); - } - return TRUE; - } - catch (\Exception $e) { - $this->logger->error("The invalid dataset data could not be purged due to @message", [ - '@message' => $e->getMessage(), - ]); - } - return FALSE; - } - - /** - * Returns the actual index id. - */ - protected function getFullIndexId(string $machineName): string { - $hashPrefix = $this->configuration['hash_prefix'] ?? ''; - $prefix = $this->configuration['prefix'] ?? ''; - - if ($hashPrefix && $prefix) { - return "{$hashPrefix}--{$prefix}{$machineName}"; - } - - return ($prefix ?: '') . $machineName; - } - -}