pub struct Searcher<D: Directory + 'static> { /* private fields */ }Expand description
Searcher - provides search over loaded segments
For wasm/read-only use, create via Searcher::open().
For native use with Index, this is created via IndexReader.
Implementations§
Source§impl<D: Directory + 'static> Searcher<D>
impl<D: Directory + 'static> Searcher<D>
Sourcepub async fn open(
directory: Arc<D>,
schema: Arc<Schema>,
segment_ids: &[String],
term_cache_blocks: usize,
) -> Result<Self>
pub async fn open( directory: Arc<D>, schema: Arc<Schema>, segment_ids: &[String], term_cache_blocks: usize, ) -> Result<Self>
Create a Searcher directly from segment IDs
This is a simpler initialization path that doesn’t require SegmentManager. Use this for read-only access to pre-built indexes.
Sourcepub fn segment_readers(&self) -> &[Arc<SegmentReader>]
pub fn segment_readers(&self) -> &[Arc<SegmentReader>]
Get segment readers
Sourcepub fn default_fields(&self) -> &[Field]
pub fn default_fields(&self) -> &[Field]
Get default fields for search
Sourcepub fn tokenizers(&self) -> &TokenizerRegistry
pub fn tokenizers(&self) -> &TokenizerRegistry
Get tokenizer registry
Sourcepub fn trained_centroids(&self) -> &FxHashMap<u32, Arc<CoarseCentroids>>
pub fn trained_centroids(&self) -> &FxHashMap<u32, Arc<CoarseCentroids>>
Get trained centroids
Sourcepub fn global_stats(&self) -> &Arc<LazyGlobalStats>
pub fn global_stats(&self) -> &Arc<LazyGlobalStats>
Get lazy global statistics for cross-segment IDF computation
Sourcepub fn segment_map(&self) -> &FxHashMap<u128, usize>
pub fn segment_map(&self) -> &FxHashMap<u128, usize>
Get O(1) segment_id → index map (used by reranker)
Sourcepub fn num_segments(&self) -> usize
pub fn num_segments(&self) -> usize
Get number of segments
Sourcepub async fn doc(&self, doc_id: u32) -> Result<Option<Document>>
pub async fn doc(&self, doc_id: u32) -> Result<Option<Document>>
Get a document by global doc_id (binary search on cumulative offsets)
Sourcepub async fn search(
&self,
query: &dyn Query,
limit: usize,
) -> Result<Vec<SearchResult>>
pub async fn search( &self, query: &dyn Query, limit: usize, ) -> Result<Vec<SearchResult>>
Search across all segments and return aggregated results
Sourcepub async fn search_with_count(
&self,
query: &dyn Query,
limit: usize,
) -> Result<(Vec<SearchResult>, u32)>
pub async fn search_with_count( &self, query: &dyn Query, limit: usize, ) -> Result<(Vec<SearchResult>, u32)>
Search across all segments and return (results, total_seen) total_seen is the number of documents that were scored across all segments
Sourcepub async fn search_with_offset(
&self,
query: &dyn Query,
limit: usize,
offset: usize,
) -> Result<Vec<SearchResult>>
pub async fn search_with_offset( &self, query: &dyn Query, limit: usize, offset: usize, ) -> Result<Vec<SearchResult>>
Search with offset for pagination
Sourcepub async fn search_with_offset_and_count(
&self,
query: &dyn Query,
limit: usize,
offset: usize,
) -> Result<(Vec<SearchResult>, u32)>
pub async fn search_with_offset_and_count( &self, query: &dyn Query, limit: usize, offset: usize, ) -> Result<(Vec<SearchResult>, u32)>
Search with offset and return (results, total_seen)
Sourcepub async fn search_with_positions(
&self,
query: &dyn Query,
limit: usize,
) -> Result<(Vec<SearchResult>, u32)>
pub async fn search_with_positions( &self, query: &dyn Query, limit: usize, ) -> Result<(Vec<SearchResult>, u32)>
Search with positions (ordinal tracking) and return (results, total_seen)
Use this when you need per-ordinal scores for multi-valued fields.
Sourcepub async fn search_and_rerank(
&self,
query: &dyn Query,
l1_limit: usize,
final_limit: usize,
config: &RerankerConfig,
) -> Result<(Vec<SearchResult>, u32)>
pub async fn search_and_rerank( &self, query: &dyn Query, l1_limit: usize, final_limit: usize, config: &RerankerConfig, ) -> Result<(Vec<SearchResult>, u32)>
Two-stage search: L1 retrieval + L2 dense vector reranking
Runs the query to get l1_limit candidates, then reranks by exact
dense vector distance and returns the top final_limit results.
Sourcepub async fn query(
&self,
query_str: &str,
limit: usize,
) -> Result<SearchResponse>
pub async fn query( &self, query_str: &str, limit: usize, ) -> Result<SearchResponse>
Parse query string and search (convenience method)
Sourcepub async fn query_offset(
&self,
query_str: &str,
limit: usize,
offset: usize,
) -> Result<SearchResponse>
pub async fn query_offset( &self, query_str: &str, limit: usize, offset: usize, ) -> Result<SearchResponse>
Parse query string and search with offset (convenience method)
Sourcepub fn query_parser(&self) -> QueryLanguageParser
pub fn query_parser(&self) -> QueryLanguageParser
Get query parser for this searcher
Sourcepub async fn get_document(
&self,
address: &DocAddress,
) -> Result<Option<Document>>
pub async fn get_document( &self, address: &DocAddress, ) -> Result<Option<Document>>
Get a document by address (segment_id + global doc_id)
The doc_id in the address is a global doc_id (with doc_id_offset applied). This method converts it back to a segment-local doc_id for the store lookup.
Sourcepub async fn get_document_with_fields(
&self,
address: &DocAddress,
fields: Option<&FxHashSet<u32>>,
) -> Result<Option<Document>>
pub async fn get_document_with_fields( &self, address: &DocAddress, fields: Option<&FxHashSet<u32>>, ) -> Result<Option<Document>>
Get a document by address, hydrating only the specified field IDs.
If fields is None, all fields are hydrated (including dense vectors).
If fields is Some(set), only dense vector fields in the set are read
from flat storage — skipping expensive mmap reads for unrequested vectors.
Auto Trait Implementations§
impl<D> Freeze for Searcher<D>
impl<D> !RefUnwindSafe for Searcher<D>
impl<D> Send for Searcher<D>
impl<D> Sync for Searcher<D>
impl<D> Unpin for Searcher<D>
impl<D> !UnwindSafe for Searcher<D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.