pub struct Searcher { /* private fields */ }
Expand description
Holds a list of SegmentReader
s ready for search.
It guarantees that the Segment
will not be removed before
the destruction of the Searcher
.
Implementations§
source§impl Searcher
impl Searcher
sourcepub fn generation(&self) -> &SearcherGeneration
pub fn generation(&self) -> &SearcherGeneration
SearcherGeneration
which identifies the version of the snapshot held by this Searcher
.
sourcepub fn doc<D: DocumentDeserialize>(&self, doc_address: DocAddress) -> Result<D>
pub fn doc<D: DocumentDeserialize>(&self, doc_address: DocAddress) -> Result<D>
Fetches a document from tantivy’s store given a DocAddress
.
The searcher uses the segment ordinal to route the
request to the right Segment
.
sourcepub fn doc_store_cache_stats(&self) -> CacheStats
pub fn doc_store_cache_stats(&self) -> CacheStats
The cache stats for the underlying store reader.
Aggregates the sum for each segment store reader.
sourcepub fn doc_freq(&self, term: &Term) -> Result<u64>
pub fn doc_freq(&self, term: &Term) -> Result<u64>
Return the overall number of documents containing the given term.
sourcepub fn segment_readers(&self) -> &[SegmentReader]
pub fn segment_readers(&self) -> &[SegmentReader]
Return the list of segment readers
sourcepub fn segment_reader(&self, segment_ord: u32) -> &SegmentReader
pub fn segment_reader(&self, segment_ord: u32) -> &SegmentReader
Returns the segment_reader associated with the given segment_ord
sourcepub fn search<C: Collector>(
&self,
query: &dyn Query,
collector: &C
) -> Result<C::Fruit>
pub fn search<C: Collector>( &self, query: &dyn Query, collector: &C ) -> Result<C::Fruit>
Runs a query on the segment readers wrapped by the searcher.
Search works as follows :
First the weight object associated with the query is created.
Then, the query loops over the segments and for each segment :
- setup the collector and informs it that the segment being processed has changed.
- creates a SegmentCollector for collecting documents associated with the segment
- creates a
Scorer
object associated for this segment - iterate through the matched documents and push them to the segment collector.
Finally, the Collector merges each of the child collectors into itself for result usability by the caller.
sourcepub fn search_with_statistics_provider<C: Collector>(
&self,
query: &dyn Query,
collector: &C,
statistics_provider: &dyn Bm25StatisticsProvider
) -> Result<C::Fruit>
pub fn search_with_statistics_provider<C: Collector>( &self, query: &dyn Query, collector: &C, statistics_provider: &dyn Bm25StatisticsProvider ) -> Result<C::Fruit>
Same as search(...)
but allows specifying
a Bm25StatisticsProvider.
This can be used to adjust the statistics used in computing BM25 scores.
sourcepub fn search_with_executor<C: Collector>(
&self,
query: &dyn Query,
collector: &C,
executor: &Executor,
enabled_scoring: EnableScoring<'_>
) -> Result<C::Fruit>
pub fn search_with_executor<C: Collector>( &self, query: &dyn Query, collector: &C, executor: &Executor, enabled_scoring: EnableScoring<'_> ) -> Result<C::Fruit>
Same as search(...)
but multithreaded.
The current implementation is rather naive : multithreading is by splitting search into as many task as there are segments.
It is powerless at making search faster if your index consists in one large segment.
Also, keep in my multithreading a single query on several threads will not improve your throughput. It can actually hurt it. It will however, decrease the average response time.
sourcepub fn space_usage(&self) -> Result<SearcherSpaceUsage>
pub fn space_usage(&self) -> Result<SearcherSpaceUsage>
Summarize total space usage of this searcher.
Trait Implementations§
source§impl Bm25StatisticsProvider for Searcher
impl Bm25StatisticsProvider for Searcher
Auto Trait Implementations§
impl Freeze for Searcher
impl !RefUnwindSafe for Searcher
impl Send for Searcher
impl Sync for Searcher
impl Unpin for Searcher
impl !UnwindSafe for Searcher
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.