idx searchAccepted
idx search already supports metadata path filtering via --path, where
filtering is applied before result rendering and integrated with the ranking
pipeline. This is useful for narrowing scope by directory, but it does not
solve a common workflow need: restricting search to a file type across the
whole project (for example, only .go files).
Without an extension-aware filter in the index model, the command would need to infer extension constraints by scanning all candidate document paths at query time. That approach is more expensive, harder to combine with existing metadata filters, and less consistent with the current indexed-metadata design (ADR 0003).
The desired behavior is:
--ext go).go or .go).Introduce a repeatable --ext flag for idx search and index file extensions
as dedicated metadata terms.
Add --ext as a repeatable search flag:
idx search query --ext goidx search query --ext .goidx search --ext go (metadata-only search)--ext participates in the same validation contract as other metadata
filters: a search is valid if it has query terms, or at least one metadata
filter (--path and/or --ext).
Extend InvertedIndex with ExtensionTerms map[string]map[string]bool and
populate it during indexing.
Normalization rule for stored extension terms:
.Examples:
.GO -> gogo -> goApply extension filtering in the metadata matching stage, after path filtering and before score filtering/ranking output.
Effective behavior:
metadataMatchedDocuments computes all indexed docs--path constraints--ext constraintsfilteredScoresThis keeps ranking semantics unchanged: BM25 still ranks the surviving candidate set, and metadata-only queries still receive uniform scores.
Normalize extension filters in normalizedSearchOptions so equivalent inputs
map to the same internal representation.
Include extension filters in the search cache key to avoid cross-contamination between cached results for different extension constraints.
--path behavior.go and .go should behave identically.--ext.idx search --ext go).ExtensionTerms.DocStats.Path at query time only (no indexed terms).Rejected because it would require full candidate scans for every extension query and duplicate logic already solved by indexed metadata filters.
PathTerms for extension matching.Rejected because path tokenization semantics are broader than extension semantics and can introduce ambiguous matches; a dedicated metadata field is clearer and more maintainable.
Rejected because extension is a hard filter concern, not a relevance signal. Using BM25 terms alone would not provide strict file-type filtering.
Implementation points:
internal/adapters/handlers/cli/cobra_commands.gointernal/core/ports/search_options.gointernal/core/domain/inverted_index.gointernal/core/services/indexing/bm25_index_service.gointernal/core/services/search/search_metadata_filter.gointernal/core/services/search/search_result_options_output.goTest coverage includes:
--ext