Skip to content

Repository CreateAndAliasIndex matches missing index error too specifically #969

@yelly

Description

@yelly

In both HashRepository.CreateAndAliasIndex and JSONRepository.CreateAndAliasIndex the error message returned from the FT.INFO command is matched against the string "Unknown index name" when verifying whether the index exists.
At least in Redis 8 OSS this is not the message returned in this case (it's "no such index"), causing the operation to fail on DBs in which the index was not yet created.
This approach is fragile. Instead we can use FT._LIST to list the indexes and check there whether any indexes exist matching the pattern (the alias won't show up there). There is also an opportunity here to share code between HashRepository and JSONRepository (the functions in both are almost identical).
I'll try to have a PR for this early next week.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions