[][src]Struct tantivy::Searcher

pub struct Searcher { /* fields omitted */ }

Holds a list of SegmentReaders ready for search.

It guarantees that the Segment will not be removed before the destruction of the Searcher.


impl Searcher[src]

pub fn index(&self) -> &Index[src]

Returns the Index associated to the Searcher

pub fn doc(&self, doc_address: DocAddress) -> Result<Document>[src]

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.

pub fn schema(&self) -> &Schema[src]

Access the schema associated to the index of this searcher.

pub fn num_docs(&self) -> u64[src]

Returns the overall number of documents in the index.

pub fn doc_freq(&self, term: &Term) -> u64[src]

Return the overall number of documents containing the given term.

pub fn segment_readers(&self) -> &[SegmentReader][src]

Return the list of segment readers

pub fn segment_reader(&self, segment_ord: u32) -> &SegmentReader[src]

Returns the segment_reader associated with the given segment_ordinal

pub fn search<C: Collector>(
    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.

pub fn search_with_executor<C: Collector>(
    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.

pub fn field(&self, field: Field) -> FieldSearcher[src]

Return the field searcher associated to a Field.

pub fn space_usage(&self) -> SearcherSpaceUsage[src]

Summarize total space usage of this searcher.

Trait Implementations

impl Debug for Searcher[src]

Auto Trait Implementations

impl !Sync for Searcher

impl Send for Searcher

impl Unpin for Searcher

impl !UnwindSafe for Searcher

impl !RefUnwindSafe for Searcher

Blanket Implementations

impl<T> Fruit for T where
    T: Send + Downcast

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Erased for T[src]

impl<T> Downcast for T where
    T: Any