Skip to content

Improve list_indices to discover indices via _settings pattern fallback #33

@kapral18

Description

@kapral18

Problem

Currently, list_indices only discovers indices by looking for aliases ending with -repo. However, the semantic-code-search-indexer doesn't automatically create such aliases when indexing a repository. This creates a workflow issue where users must manually:

  1. Create an index with <index>-repo name
  2. Add a <index>-repo alias

This is a design omission that makes the tool less user-friendly.

Solution

Implement a dual discovery strategy:

  1. Primary: Continue to discover indices via aliases ending with -repo (backward compatible)
  2. Fallback: Discover indices by finding all indices ending with _settings, extracting the base name, and verifying the base index exists

The indexer creates both <name> and <name>_settings indices, so we can identify repos by the _settings pattern.

Implementation

  • Add discoverRepoIndicesFromAliases() function (primary strategy)
  • Add discoverRepoIndicesFromSettings() function (fallback strategy)
  • Merge and deduplicate results (aliases take precedence for display names)
  • Update both listIndices() and getAvailableIndices() to use the same discovery logic
  • Add comprehensive test coverage including console.warn verification

Benefits

  • Works immediately with current indexer behavior (no manual alias creation needed)
  • Maintains backward compatibility with existing -repo aliases
  • Provides clear migration path for future indexer improvements
  • Future-proof: works with both old and new indexer versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions