Skip to main content

Query

Trait Query 

Source
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§

Source

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.

Source

fn count_estimate<'a>(&self, reader: &'a SegmentReader) -> CountFuture<'a>

Estimated number of matching documents in a segment (async)

Provided Methods§

Source

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.)

Trait Implementations§

Source§

impl Query for Box<dyn Query>

Source§

fn scorer<'a>( &self, reader: &'a SegmentReader, limit: usize, ) -> ScorerFuture<'a>

Create a scorer for this query against a single segment (async) Read more
Source§

fn count_estimate<'a>(&self, reader: &'a SegmentReader) -> CountFuture<'a>

Estimated number of matching documents in a segment (async)
Source§

fn as_term_query_info(&self) -> Option<TermQueryInfo>

Return term info if this is a simple term query eligible for WAND optimization Read more

Implementations on Foreign Types§

Source§

impl Query for Box<dyn Query>

Source§

fn scorer<'a>( &self, reader: &'a SegmentReader, limit: usize, ) -> ScorerFuture<'a>

Source§

fn count_estimate<'a>(&self, reader: &'a SegmentReader) -> CountFuture<'a>

Source§

fn as_term_query_info(&self) -> Option<TermQueryInfo>

Implementors§