Expand description
§QueryIndex
§File: Indexing/Store/QueryIndex.rs
§Role in Air Architecture
Provides index query functionality for the File Indexer service, handling search operations across indexed files with multiple search modes.
§Primary Responsibility
Query the file index to find symbols and content matching search criteria, supporting literal, regex, fuzzy, and exact search modes.
§Secondary Responsibilities
- Multi-mode search (literal, regex, fuzzy, exact)
- Case sensitivity and whole word matching
- Path and language filtering
- Result pagination and ranking
- Search query sanitization
§Dependencies
External Crates:
regex- Regular expression search patternstokio- Async file I/O operations
Internal Modules:
crate::Result- Error handling typecrate::AirError- Error typessuper::super::FileIndex- Index structure definitions
§Dependents
Indexing::mod::FileIndexer- Main file indexer implementation
§VSCode Pattern Reference
Inspired by VSCode’s search functionality in
src/vs/workbench/services/search/common/
§Security Considerations
- Search query sanitization prevents injection
- Query length limits
- Control character filtering
§Performance Considerations
- Content index for fast token lookup
- Result pagination to limit memory usage
- Efficient string matching algorithms
- Fuzzy search with configurable distance
§Error Handling Strategy
Query operations return detailed error messages for invalid queries or search failures, treating individual file read errors as warnings.
§Thread Safety
Query operations read from shared Arc<RwLock<>> state and return safe-ownership results for the caller.
Structs§
- Paginated
Search Results - Paginated search results
- Search
Match - Search match with full context
- Search
Query - Search query with multiple modes
- Search
Result - Search result with relevance scoring
Enums§
- Search
Mode - Search mode
Constants§
- MAX_
SEARCH_ RESULTS_ DEFAULT - Maximum search results per query (pagination default)
Functions§
- Calculate
Levenshtein 🔒Distance - Calculate Levenshtein distance between two strings
- Calculate
Relevance 🔒 - Calculate relevance score for search results
- Find
Exact 🔒Matches - Find exact matches (word boundary and case-sensitive)
- Find
Fuzzy 🔒Matches - Find fuzzy matches using Levenshtein distance algorithm
- Find
Matches 🔒InFile - Find matches in a single file with context
- Find
Matches 🔒With Context - Find matches in content with surrounding context
- Find
Regex 🔒Matches - Find regex matches in content
- Find
Whole 🔒Word Match - Find whole word match with word boundary detection
- Matches
Filters - Check if file matches filters
- Query
Index 🔒Exact - Exact match search (whole word, case-sensitive)
- Query
Index 🔒Fuzzy - Fuzzy search with typo tolerance using Levenshtein distance
- Query
Index 🔒Literal - Literal search (default mode)
- Query
Index 🔒Regex - Regex search mode
- Query
Index Search - Search files with multiple modes and comprehensive query handling
- Sanitize
Search Query - Sanitize search query to prevent injection and invalid patterns