[−][src]Trait tantivy::query::Query
The Query
trait defines a set of documents and a scoring method
for those documents.
The Query
trait is in charge of defining :
- a set of documents
- a way to score these documents
When performing a search, these documents will then be pushed to a Collector, which will in turn be in charge of deciding what to do with them.
Concretely, this scored docset is represented by the
Scorer
trait.
Because our index is actually split into segments, the
query does not actually directly creates DocSet
object.
Instead, the query creates a Weight
object for a given searcher.
The weight object, in turn, makes it possible to create
a scorer for a specific SegmentReader
.
So to sum it up :
- a
Query
is recipe to define a set of documents as well the way to score them. - a
Weight
is this recipe tied to a specificSearcher
. It may for instance hold statistics about the different term of the query. It is created by the query. - a
Scorer
is a cursor over the set of matching documents, for a specificSegmentReader
. It is created by theWeight
.
When implementing a new type of Query
, it is normal to implement a
dedicated Query
, Weight
and Scorer
.
Required methods
fn weight(
&self,
searcher: &Searcher,
scoring_enabled: bool
) -> Result<Box<dyn Weight>>
&self,
searcher: &Searcher,
scoring_enabled: bool
) -> Result<Box<dyn Weight>>
Create the weight associated to a query.
If scoring is not required, setting scoring_enabled
to false
can increase performances.
See Weight
.
Provided methods
fn count(&self, searcher: &Searcher) -> Result<usize>
Returns the number of documents matching the query.
fn query_terms(&self, _term_set: &mut BTreeSet<Term>)
Extract all of the terms associated to the query and insert them in the term set given in arguments.
Methods
impl dyn Query
pub fn is<__T: Query>(&self) -> bool
Returns true if the trait object wraps an object of type __T
.
pub fn downcast<__T: Query>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>
Returns a boxed object from a boxed trait object if the underlying object is of type
__T
. Returns the original boxed trait if it isn't.
pub fn downcast_ref<__T: Query>(&self) -> Option<&__T>
Returns a reference to the object within the trait object if it is of type __T
, or
None
if it isn't.
pub fn downcast_mut<__T: Query>(&mut self) -> Option<&mut __T>
Returns a mutable reference to the object within the trait object if it is of type
__T
, or None
if it isn't.
Implementations on Foreign Types
impl Query for Box<dyn Query>
[src]
fn weight(
&self,
searcher: &Searcher,
scoring_enabled: bool
) -> Result<Box<dyn Weight>>
[src]
&self,
searcher: &Searcher,
scoring_enabled: bool
) -> Result<Box<dyn Weight>>
fn count(&self, searcher: &Searcher) -> Result<usize>
[src]
fn query_terms(&self, term_set: &mut BTreeSet<Term<Vec<u8>>>)
[src]
Implementors
impl Query for AllQuery
[src]
fn weight(&self, _: &Searcher, _: bool) -> Result<Box<dyn Weight>>
[src]
fn count(&self, searcher: &Searcher) -> Result<usize>
[src]
fn query_terms(&self, _term_set: &mut BTreeSet<Term>)
[src]
impl Query for BooleanQuery
[src]
fn weight(
&self,
searcher: &Searcher,
scoring_enabled: bool
) -> Result<Box<dyn Weight>>
[src]
&self,
searcher: &Searcher,
scoring_enabled: bool
) -> Result<Box<dyn Weight>>
fn query_terms(&self, term_set: &mut BTreeSet<Term>)
[src]
fn count(&self, searcher: &Searcher) -> Result<usize>
[src]
impl Query for EmptyQuery
[src]
fn weight(
&self,
_searcher: &Searcher,
_scoring_enabled: bool
) -> Result<Box<dyn Weight>>
[src]
&self,
_searcher: &Searcher,
_scoring_enabled: bool
) -> Result<Box<dyn Weight>>
fn count(&self, _searcher: &Searcher) -> Result<usize>
[src]
fn query_terms(&self, _term_set: &mut BTreeSet<Term>)
[src]
impl Query for FuzzyTermQuery
[src]
fn weight(
&self,
_searcher: &Searcher,
_scoring_enabled: bool
) -> Result<Box<dyn Weight>>
[src]
&self,
_searcher: &Searcher,
_scoring_enabled: bool
) -> Result<Box<dyn Weight>>
fn count(&self, searcher: &Searcher) -> Result<usize>
[src]
fn query_terms(&self, _term_set: &mut BTreeSet<Term>)
[src]
impl Query for PhraseQuery
[src]
fn weight(
&self,
searcher: &Searcher,
scoring_enabled: bool
) -> Result<Box<dyn Weight>>
[src]
&self,
searcher: &Searcher,
scoring_enabled: bool
) -> Result<Box<dyn Weight>>
Create the weight associated to a query.
See Weight
.
fn query_terms(&self, term_set: &mut BTreeSet<Term>)
[src]
fn count(&self, searcher: &Searcher) -> Result<usize>
[src]
impl Query for RangeQuery
[src]
fn weight(
&self,
searcher: &Searcher,
_scoring_enabled: bool
) -> Result<Box<dyn Weight>>
[src]
&self,
searcher: &Searcher,
_scoring_enabled: bool
) -> Result<Box<dyn Weight>>
fn count(&self, searcher: &Searcher) -> Result<usize>
[src]
fn query_terms(&self, _term_set: &mut BTreeSet<Term>)
[src]
impl Query for RegexQuery
[src]
fn weight(
&self,
_searcher: &Searcher,
_scoring_enabled: bool
) -> Result<Box<dyn Weight>>
[src]
&self,
_searcher: &Searcher,
_scoring_enabled: bool
) -> Result<Box<dyn Weight>>