Issue #3563399: Prevent data loss when updating index schema

This patch fixes a critical bug where running config import (drush cim) after adding new fields to a Search API index would drop the entire Typesense collection, resulting in loss of all indexed documents.

Changes:

  • Add updateCollectionSchema() method to TypesenseClient that uses Typesense's PATCH API to modify collection schema in-place
  • Rewrite updateIndex() to compare schemas and only add/remove changed fields instead of dropping and recreating the collection
  • Only trigger reindex when new fields are added (so data gets populated)
  • Preserve 'id' field which is special in Typesense
  • Re-throw exceptions to make errors visible to the user

This approach preserves all existing indexed documents while still allowing schema changes through config import.

Closes #3563399

Merge request reports

Loading