pub trait Query: Send + Sync {
// Required methods
fn scorer<'a>(
&self,
reader: &'a SegmentReader,
limit: usize,
) -> ScorerFuture<'a>;
fn count_estimate<'a>(&self, reader: &'a SegmentReader) -> CountFuture<'a>;
// Provided method
fn as_term_query_info(&self) -> Option<TermQueryInfo> { ... }
}Expand description
A search query (async)
Note: scorer takes &self (not &'a self) so that scorers don’t borrow the query.
This enables query composition - queries can create sub-queries locally and get their scorers.
Implementations must clone/capture any data they need during scorer creation.
Required Methods§
Sourcefn scorer<'a>(
&self,
reader: &'a SegmentReader,
limit: usize,
) -> ScorerFuture<'a>
fn scorer<'a>( &self, reader: &'a SegmentReader, limit: usize, ) -> ScorerFuture<'a>
Create a scorer for this query against a single segment (async)
The limit parameter specifies the maximum number of results to return.
This is passed from the top-level search limit.
Note: The scorer borrows only the reader, not the query. Implementations should capture any needed query data (field, terms, etc.) during creation.
Sourcefn count_estimate<'a>(&self, reader: &'a SegmentReader) -> CountFuture<'a>
fn count_estimate<'a>(&self, reader: &'a SegmentReader) -> CountFuture<'a>
Estimated number of matching documents in a segment (async)
Provided Methods§
Sourcefn as_term_query_info(&self) -> Option<TermQueryInfo>
fn as_term_query_info(&self) -> Option<TermQueryInfo>
Return term info if this is a simple term query eligible for WAND optimization
Returns None for complex queries (boolean, phrase, etc.)