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
sourceimpl 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(&self, doc_address: DocAddress) -> Result<Document>
pub fn doc(&self, doc_address: DocAddress) -> Result<Document>
Fetches a document from tantivy’s store given a DocAddress
.
The searcher uses the segment ordinal to route the
the request to the right Segment
.
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 to 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 to 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_executor<C: Collector>(
&self,
query: &dyn Query,
collector: &C,
executor: &Executor
) -> Result<C::Fruit>
pub fn search_with_executor<C: Collector>(
&self,
query: &dyn Query,
collector: &C,
executor: &Executor
) -> 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
Auto Trait Implementations
impl !RefUnwindSafe for Searcher
impl Send for Searcher
impl Sync for Searcher
impl Unpin for Searcher
impl !UnwindSafe for Searcher
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert 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
. Read more
sourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more