[][src]Struct tantivy::query::RangeQuery

pub struct RangeQuery { /* fields omitted */ }

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]

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]

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]

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]

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]

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]

impl Debug for RangeQuery[src]

impl Query for RangeQuery[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

impl<T> Erased for T[src]

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

impl<T> Fruit for T where
    T: Send + Downcast
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,