pub struct PhraseQuery {
pub field: Field,
pub terms: Vec<Vec<u8>>,
pub offsets: Vec<u32>,
pub slop: u32,
/* private fields */
}Expand description
Phrase query - matches documents containing terms in consecutive positions
Example: “quick brown fox” matches only if all three terms appear consecutively in the document.
Fields§
§field: Field§terms: Vec<Vec<u8>>Terms in the phrase, in order
offsets: Vec<u32>Token offset of each term inside the phrase, ascending, one per term.
offsets[i + 1] - offsets[i] is the required distance between two
consecutive terms: 1 for adjacent words, more when index-time stop
words were dropped between them (quantum@0 art@3). PhraseQuery::new
makes every term adjacent.
slop: u32Optional slop (max distance between terms, 0 = exact phrase)
Implementations§
Source§impl PhraseQuery
impl PhraseQuery
Sourcepub fn new(field: Field, terms: Vec<Vec<u8>>) -> Self
pub fn new(field: Field, terms: Vec<Vec<u8>>) -> Self
Create a new exact phrase query of adjacent terms.
Sourcepub fn with_offsets(field: Field, terms: Vec<(u32, Vec<u8>)>) -> Self
pub fn with_offsets(field: Field, terms: Vec<(u32, Vec<u8>)>) -> Self
Create a phrase whose terms carry their token offsets, as produced by
a tokenizer that drops stop words without renumbering ((0, quantum),
(3, art) for “quantum of the art”). Offsets must be ascending.
Sourcepub fn text(field: Field, phrase: &str) -> Self
pub fn text(field: Field, phrase: &str) -> Self
Create from text using the simple tokenizer (whitespace split,
punctuation stripped, lowercased). Fields with a stemming tokenizer
should tokenize the phrase themselves and call
PhraseQuery::with_offsets so the query terms match the indexed
stems and keep the gaps of dropped stop words.
Sourcepub fn with_global_stats(self, stats: Arc<GlobalStats>) -> Self
pub fn with_global_stats(self, stats: Arc<GlobalStats>) -> Self
Set global statistics for cross-segment IDF
Trait Implementations§
Source§impl Clone for PhraseQuery
impl Clone for PhraseQuery
Source§fn clone(&self) -> PhraseQuery
fn clone(&self) -> PhraseQuery
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PhraseQuery
impl Debug for PhraseQuery
Source§impl Display for PhraseQuery
impl Display for PhraseQuery
Source§impl Query for PhraseQuery
impl Query for PhraseQuery
Source§fn as_doc_bitset(&self, reader: &SegmentReader) -> Option<DocBitset>
fn as_doc_bitset(&self, reader: &SegmentReader) -> Option<DocBitset>
Every document containing the phrase, as a bitset (documents, also for chunked fields). Lets the planner push a quoted span into the MaxScore executors as an O(1) predicate instead of a verifier.
Source§fn bitset_cardinality_estimate(&self, reader: &SegmentReader) -> Option<u64>
fn bitset_cardinality_estimate(&self, reader: &SegmentReader) -> Option<u64>
Matches are at most the rarest term’s postings; the planner only needs the order of magnitude to pick which clause to materialize.
Source§fn text_terms(&self, out: &mut Vec<(Field, Vec<u8>)>)
fn text_terms(&self, out: &mut Vec<(Field, Vec<u8>)>)
(field, term) this query scores with BM25 to
out. The searcher aggregates their document frequencies
across segments before scoring (see ScorerOptions::global_stats).Source§fn scorer<'a>(
&self,
reader: &'a SegmentReader,
limit: usize,
) -> ScorerFuture<'a>
fn scorer<'a>( &self, reader: &'a SegmentReader, limit: usize, ) -> ScorerFuture<'a>
Source§fn scorer_with_options<'a>(
&self,
reader: &'a SegmentReader,
limit: usize,
options: ScorerOptions,
) -> ScorerFuture<'a>
fn scorer_with_options<'a>( &self, reader: &'a SegmentReader, limit: usize, options: ScorerOptions, ) -> ScorerFuture<'a>
Source§fn scorer_sync<'a>(
&self,
reader: &'a SegmentReader,
limit: usize,
) -> Result<Box<dyn Scorer + 'a>>
fn scorer_sync<'a>( &self, reader: &'a SegmentReader, limit: usize, ) -> Result<Box<dyn Scorer + 'a>>
Source§fn scorer_sync_with_options<'a>(
&self,
reader: &'a SegmentReader,
limit: usize,
options: ScorerOptions,
) -> Result<Box<dyn Scorer + 'a>>
fn scorer_sync_with_options<'a>( &self, reader: &'a SegmentReader, limit: usize, options: ScorerOptions, ) -> Result<Box<dyn Scorer + 'a>>
Query::scorer_with_options.Source§fn count_estimate<'a>(&self, reader: &'a SegmentReader) -> CountFuture<'a>
fn count_estimate<'a>(&self, reader: &'a SegmentReader) -> CountFuture<'a>
Source§fn decompose(&self) -> QueryDecomposition
fn decompose(&self) -> QueryDecomposition
Source§fn is_filter(&self) -> bool
fn is_filter(&self) -> bool
Source§fn as_doc_predicate<'a>(
&self,
_reader: &'a SegmentReader,
) -> Option<DocPredicate<'a>>
fn as_doc_predicate<'a>( &self, _reader: &'a SegmentReader, ) -> Option<DocPredicate<'a>>
Auto Trait Implementations§
impl Freeze for PhraseQuery
impl RefUnwindSafe for PhraseQuery
impl Send for PhraseQuery
impl Sync for PhraseQuery
impl Unpin for PhraseQuery
impl UnsafeUnpin for PhraseQuery
impl UnwindSafe for PhraseQuery
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<E> ResultError for E
impl<T> ResultType for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more