[−][src]Struct tantivy::query::RegexQuery
A Regex Query matches all of the documents containing a specific term that matches a regex pattern.
use tantivy::collector::Count; use tantivy::query::RegexQuery; use tantivy::schema::{Schema, TEXT}; use tantivy::{doc, Index, Term}; 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)?; index_writer.add_document(doc!( title => "The Name of the Wind", )); index_writer.add_document(doc!( title => "The Diary of Muadib", )); index_writer.add_document(doc!( title => "A Dairy Cow", )); index_writer.add_document(doc!( title => "The Diary of a Young Girl", )); index_writer.commit().unwrap(); } let reader = index.reader()?; let searcher = reader.searcher(); let term = Term::from_field_text(title, "Diary"); let query = RegexQuery::from_pattern("d[ai]{2}ry", title)?; let count = searcher.search(&query, &Count)?; assert_eq!(count, 3); Ok(())
Methods
impl RegexQuery
[src]
pub fn from_pattern(regex_pattern: &str, field: Field) -> Result<Self>
[src]
Creates a new RegexQuery from a given pattern
pub fn from_regex<T: Into<Arc<Regex>>>(regex: T, field: Field) -> Self
[src]
Creates a new RegexQuery from a fully built Regex
Trait Implementations
impl Clone for RegexQuery
[src]
fn clone(&self) -> RegexQuery
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for RegexQuery
[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>>
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 RegexQuery
impl Send for RegexQuery
impl Sync for RegexQuery
impl Unpin for RegexQuery
impl UnwindSafe for RegexQuery
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>,