From 34b2b456ae7845178abd9b4dbe1fce88c50b2574 Mon Sep 17 00:00:00 2001
From: Kalle Vuorjoki <21761-kallevu@users.noreply.drupalcode.org>
Date: Fri, 6 Jan 2023 08:03:35 +0000
Subject: [PATCH] Issue #3153850 by sokru, littlepixiez, Roderik de Langen,
 IT-Cru: Make sure we are dealing with an Elasticsearch backend on
 IndexFactory

---
 src/ElasticSearch/Parameters/Factory/IndexFactory.php | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/ElasticSearch/Parameters/Factory/IndexFactory.php b/src/ElasticSearch/Parameters/Factory/IndexFactory.php
index 8061b1778..8427984df 100644
--- a/src/ElasticSearch/Parameters/Factory/IndexFactory.php
+++ b/src/ElasticSearch/Parameters/Factory/IndexFactory.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory;
 
+use Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend;
 use Drupal\search_api\IndexInterface;
 use Drupal\elasticsearch_connector\Event\PrepareIndexEvent;
 use Drupal\elasticsearch_connector\Event\PrepareIndexMappingEvent;
@@ -229,6 +230,12 @@ class IndexFactory {
    */
   public static function getIndexName(IndexInterface $index) {
 
+    $backend = $index->getServerInstance()->getBackend();
+    // Make sure we are dealing with an Elasticsearch backend.
+    if (!$backend instanceof SearchApiElasticsearchBackend) {
+      return '';
+    }
+
     // Get index machine name.
     $index_machine_name = is_string($index) ? $index : $index->id();
 
-- 
GitLab