Skip to main content

SearchableIndex

Trait SearchableIndex 

Source
pub trait SearchableIndex: Send + Sync {
    // Required methods
    fn chunks(&self) -> &[CodeChunk];
    fn search(
        &self,
        query_text: &str,
        top_k: usize,
        mode: SearchMode,
    ) -> Vec<(usize, f32)>;
    fn search_from_chunk(
        &self,
        chunk_idx: usize,
        query_text: &str,
        top_k: usize,
        mode: SearchMode,
    ) -> Vec<(usize, f32)>;
}
Expand description

Engine-agnostic searchable index.

Implementations: HybridIndex for transformer engines, RipvecIndex for the ripvec engine.

Required Methods§

Source

fn chunks(&self) -> &[CodeChunk]

Borrow the indexed chunks.

Source

fn search( &self, query_text: &str, top_k: usize, mode: SearchMode, ) -> Vec<(usize, f32)>

Search by text query.

Returns (chunk_idx, score) pairs ranked descending. Score is normalized to [0, 1] regardless of mode so callers can apply a single threshold consistently.

Source

fn search_from_chunk( &self, chunk_idx: usize, query_text: &str, top_k: usize, mode: SearchMode, ) -> Vec<(usize, f32)>

Search by similarity to an existing chunk’s embedding.

Caller passes the chunk index whose embedding should be used as the query vector. The canonical goto_definition pattern: the LSP layer identifies the chunk at the cursor, then asks the index for structurally similar chunks elsewhere.

If chunk_idx is out of range or the engine cannot provide an embedding for it (keyword-only mode, embedding row not stored), implementations fall back to text-only search via Self::search.

Implementors§