[−][src]Struct tantivy::collector::Count
CountCollector
collector only counts how many
documents match the query.
use tantivy::collector::Count; use tantivy::query::QueryParser; use tantivy::schema::{Schema, TEXT}; use tantivy::{doc, Index}; let mut schema_builder = Schema::builder(); let title = schema_builder.add_text_field("title", TEXT); let schema = schema_builder.build(); let index = Index::create_in_ram(schema); let mut index_writer = index.writer(3_000_000).unwrap(); index_writer.add_document(doc!(title => "The Name of the Wind")); index_writer.add_document(doc!(title => "The Diary of Muadib")); index_writer.add_document(doc!(title => "A Dairy Cow")); index_writer.add_document(doc!(title => "The Diary of a Young Girl")); assert!(index_writer.commit().is_ok()); let reader = index.reader().unwrap(); let searcher = reader.searcher(); // Here comes the important part let query_parser = QueryParser::for_index(&index, vec![title]); let query = query_parser.parse_query("diary").unwrap(); let count = searcher.search(&query, &Count).unwrap(); assert_eq!(count, 2);
Trait Implementations
impl Collector for Count
[src]
type Fruit = usize
Fruit
is the type for the result of our collection. e.g. usize
for the Count
collector. Read more
type Child = SegmentCountCollector
Type of the SegmentCollector
associated to this collector.
fn for_segment(
&self,
_: SegmentLocalId,
_: &SegmentReader
) -> Result<SegmentCountCollector>
[src]
&self,
_: SegmentLocalId,
_: &SegmentReader
) -> Result<SegmentCountCollector>
fn requires_scoring(&self) -> bool
[src]
fn merge_fruits(&self, segment_counts: Vec<usize>) -> Result<usize>
[src]
Auto Trait Implementations
impl RefUnwindSafe for Count
impl Send for Count
impl Sync for Count
impl Unpin for Count
impl UnwindSafe for Count
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
[src]
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
fn as_any(&self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> DowncastSync for T where
T: Send + Sync + Any,
[src]
T: Send + Sync + Any,
impl<T> Erased for T
[src]
impl<T> From<T> for T
[src]
impl<T> Fruit for T where
T: Send + Downcast,
[src]
T: Send + Downcast,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,