[−][src]Struct tantivy::query::RangeQuery
RangeQuery
match all documents that have at least one term within a defined range.
Matched document will all get a constant Score
of one.
Implementation
The current implement will iterate over the terms within the range
and append all of the document cross into a BitSet
.
Example
use tantivy::collector::Count; use tantivy::query::RangeQuery; use tantivy::schema::{Schema, INDEXED}; use tantivy::{doc, Index}; let mut schema_builder = Schema::builder(); let year_field = schema_builder.add_u64_field("year", INDEXED); let schema = schema_builder.build(); let index = Index::create_in_ram(schema); let mut index_writer = index.writer_with_num_threads(1, 6_000_000)?; for year in 1950u64..2017u64 { let num_docs_within_year = 10 + (year - 1950) * (year - 1950); for _ in 0..num_docs_within_year { index_writer.add_document(doc!(year_field => year)); } } index_writer.commit()?; let reader = index.reader()?; let searcher = reader.searcher(); let docs_in_the_sixties = RangeQuery::new_u64(year_field, 1960..1970); let num_60s_books = searcher.search(&docs_in_the_sixties, &Count)?; assert_eq!(num_60s_books, 2285); Ok(())
Methods
impl RangeQuery
[src]
pub fn new_term_bounds(
field: Field,
value_type: Type,
left_bound: &Bound<Term>,
right_bound: &Bound<Term>
) -> RangeQuery
[src]
field: Field,
value_type: Type,
left_bound: &Bound<Term>,
right_bound: &Bound<Term>
) -> RangeQuery
Creates a new RangeQuery
from bounded start and end terms.
If the value type is not correct, something may go terribly wrong when
the Weight
object is created.
pub fn new_i64(field: Field, range: Range<i64>) -> RangeQuery
[src]
Creates a new RangeQuery
over a i64
field.
If the field is not of the type i64
, tantivy
will panic when the Weight
object is created.
pub fn new_i64_bounds(
field: Field,
left_bound: Bound<i64>,
right_bound: Bound<i64>
) -> RangeQuery
[src]
field: Field,
left_bound: Bound<i64>,
right_bound: Bound<i64>
) -> RangeQuery
Create a new RangeQuery
over a i64
field.
The two Bound
arguments make it possible to create more complex
ranges than semi-inclusive range.
If the field is not of the type i64
, tantivy
will panic when the Weight
object is created.
pub fn new_f64(field: Field, range: Range<f64>) -> RangeQuery
[src]
Creates a new RangeQuery
over a f64
field.
If the field is not of the type f64
, tantivy
will panic when the Weight
object is created.
pub fn new_f64_bounds(
field: Field,
left_bound: Bound<f64>,
right_bound: Bound<f64>
) -> RangeQuery
[src]
field: Field,
left_bound: Bound<f64>,
right_bound: Bound<f64>
) -> RangeQuery
Create a new RangeQuery
over a f64
field.
The two Bound
arguments make it possible to create more complex
ranges than semi-inclusive range.
If the field is not of the type f64
, tantivy
will panic when the Weight
object is created.
pub fn new_u64_bounds(
field: Field,
left_bound: Bound<u64>,
right_bound: Bound<u64>
) -> RangeQuery
[src]
field: Field,
left_bound: Bound<u64>,
right_bound: Bound<u64>
) -> RangeQuery
Create a new RangeQuery
over a u64
field.
The two Bound
arguments make it possible to create more complex
ranges than semi-inclusive range.
If the field is not of the type u64
, tantivy
will panic when the Weight
object is created.
pub fn new_u64(field: Field, range: Range<u64>) -> RangeQuery
[src]
Create a new RangeQuery
over a u64
field.
If the field is not of the type u64
, tantivy
will panic when the Weight
object is created.
pub fn new_str_bounds(
field: Field,
left: Bound<&str>,
right: Bound<&str>
) -> RangeQuery
[src]
field: Field,
left: Bound<&str>,
right: Bound<&str>
) -> RangeQuery
Create a new RangeQuery
over a Str
field.
The two Bound
arguments make it possible to create more complex
ranges than semi-inclusive range.
If the field is not of the type Str
, tantivy
will panic when the Weight
object is created.
pub fn new_str(field: Field, range: Range<&str>) -> RangeQuery
[src]
Create a new RangeQuery
over a Str
field.
If the field is not of the type Str
, tantivy
will panic when the Weight
object is created.
pub fn field(&self) -> Field
[src]
Field to search over
pub fn left_bound(&self) -> Bound<Term>
[src]
Lower bound of range
pub fn right_bound(&self) -> Bound<Term>
[src]
Upper bound of range
Trait Implementations
impl Clone for RangeQuery
[src]
fn clone(&self) -> RangeQuery
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for RangeQuery
[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 explain(
&self,
searcher: &Searcher,
doc_address: DocAddress
) -> Result<Explanation>
[src]
&self,
searcher: &Searcher,
doc_address: DocAddress
) -> Result<Explanation>
fn count(&self, searcher: &Searcher) -> Result<usize>
[src]
fn query_terms(&self, _term_set: &mut BTreeSet<Term>)
[src]
Auto Trait Implementations
impl RefUnwindSafe for RangeQuery
impl Send for RangeQuery
impl Sync for RangeQuery
impl Unpin for RangeQuery
impl UnwindSafe for RangeQuery
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,