When site has also other search backend than Elasticsearch, adding or clearing elasticsearch index, will provide a fatal error
"Error: Call to undefined method Drupal\search_api_db\Plugin\search_api\backend\Database::getCluster() in Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory::getIndexName() (line 236 of /docroot/modules/contrib/elasticsearch_connector/src/ElasticSearch/Parameters/Factory/IndexFactory.php)"
This is because getIndexName() on src/ElasticSearch/Parameters/Factory/IndexFactory doesn't check if the backend is SearchApiElasticsearchBackend.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | elasticsearch-cluster-error-3153850-2.patch | 3.03 KB | littlepixiez |
Issue fork elasticsearch_connector-3153850
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
littlepixiez commentedI have the same issue, but the fatal error is causing SearchAPI db tables to not be built when I change from an Elasticsearch backend to a DB backend for my indexes.
I've attached a patch to my solution - hope it's the right approach, I've just checked the backend is an instance of a "SearchApiElasticsearchBackend", and then if it isn't defaulted the prefix and suffix to a blank string as these are this-module-specific. Although this IS the function to return the Elasticsearch index name, but obviously it's no longer an Elasticsearch backend but is running the function anyway, so not sure what is best to return in this scenario - maybe the real issue is it's still calling the function after the server type has been changed and shouldn't be?
Either way, this patch helps get over the fatal error, and enables me to switch the backend server of the index without losing/breaking any functionality from either module from what I've tested.
Comment #3
littlepixiez commentedComment #6
sokru commentedThanks littlepixiez for your work. Based on your work I simplified the code a bit.
Feel free to reassign yourself in case you want to review the merge request.
Comment #7
sokru commentedComment #10
sokru commentedCrediting @IT-Cru for testing and reporting on #elasticsearch on drupal.org's Slack.