[][src]Struct tantivy::query::RegexQuery

pub struct RegexQuery { /* fields omitted */ }

containing a specific term that matches a regex pattern A Fuzzy Query matches all of the documents containing a specific term that is within Levenshtein distance

extern crate tantivy;
use tantivy::schema::{Schema, TEXT};
use tantivy::{Index, Result, Term};
use tantivy::collector::Count;
use tantivy::query::RegexQuery;

fn example() -> Result<()> {
    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)?;
            title => "The Name of the Wind",
            title => "The Diary of Muadib",
            title => "A Dairy Cow",
            title => "The Diary of a Young Girl",

    let reader = index.reader()?;
    let searcher = reader.searcher();

    let term = Term::from_field_text(title, "Diary");
    let query = RegexQuery::new("d[ai]{2}ry".to_string(), title);
    let count = searcher.search(&query, &Count)?;
    assert_eq!(count, 3);


impl RegexQuery[src]

pub fn new(regex_pattern: String, field: Field) -> RegexQuery[src]

Creates a new Fuzzy Query

Trait Implementations

impl Query for RegexQuery[src]

impl Clone for RegexQuery[src]

impl Debug for RegexQuery[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Fruit for T where
    T: Send + Downcast

impl<T, U> Into<U> for T where
    U: From<T>, 

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

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

impl<T> Erased for T[src]

impl<T> Downcast for T where
    T: Any

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