Skip to content

Changing a model-declared index definition is silently ignored for an existing index #191

Open

Description

@CaffeinatedCoder

When the context opens, DocumentCollection.ApplyIndexBuilder resolves the index name and returns early if an index with that name already exists. The existing index is rebuilt from the stored metadata in the CollectionIndexManager constructor (RebuildDefinition(idxMeta.Name, idxMeta.PropertyPaths, idxMeta.IsUnique, idxMeta.Type, idxMeta.Dimensions, idxMeta.Metric)). So when a new app version changes any of these for an index with the same name, the old definition stays in use, without a warning:

  • the unique: flag
  • vector dimensions / metric
  • the key selector / property paths (with an explicit name:)

A changed key selector with a generated name is the opposite case. The new index is added, and the old one stays and is maintained on every write until it is dropped by hand.

This was already the behaviour before #175.

Options: on open, compare the declared definition with the stored one, then either throw with a clear message or drop and rebuild the index (through the #175 backfill path, so a failure saves nothing). Model indexes that are no longer declared could be reported or dropped the same way.

Noted in the review of #175.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status
      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions