Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
public function deleteAllIndexItems(IndexInterface $index, $datasource_id = NULL) {
$this->removeIndex($index);
$this->addIndex($index);
}
Here it would be nice to preserve the index setting, like if you configured a custom tokenizer for the index or stopwords directly in ElasticSearch, you'd not like to lose it.
Comment | File | Size | Author |
---|---|---|---|
#2 | 3109361-elasticsearch_connector-preserve-index-settings-1.patch | 2.4 KB | Aron Novak |
Comments
Comment #2
Aron NovakComment #3
sokru CreditAttribution: sokru as a volunteer commentedCode is good and works like advertised, but I'm setting the status Needs work because this will override any index settings made via
elasticsearch_connector.prepare_index
EventSubscriber. E.g. if one uses something like https://git.drupalcode.org/project/elasticsearch_connector_autocomp/-/bl... to update the index settings, these will be overwritten because$this->setSettings
comes after$this->addIndex()
.I think this feature should be optional and one could set it on/off from Index options
/admin/config/search/search-api/index/{INDEX_NAME}/edit
.Comment #4
bburgThe patch in #2 still effectively deletes the index and re-creates it. This becomes an issue if you are using prefixes to share indexes between dev/live environments, where using the "Clear all indexed data" in one environment will clear the index in all environments that share it.
Is there anyway to just delete the indexed items without deleting and recreating the entire index?
Comment #5
yonailo CreditAttribution: yonailo commentedIn my opinion no ElasticSearch configuration should be added outside of Drupal. If you use 'elasticsearch_connector.prepare_index' configuration will be preserved.