pub struct QueryAnalyzer;Expand description
查询分析器
自动检测查询字符串的类型并提取实际查询内容。
Implementations§
Source§impl QueryAnalyzer
impl QueryAnalyzer
Sourcepub fn analyze(query_str: &str) -> (QueryType, String)
pub fn analyze(query_str: &str) -> (QueryType, String)
分析查询字符串,返回查询类型和清理后的查询内容
§规则
- 以
*结尾 → 前缀搜索,去除* - 以
~开头 → 模糊搜索,去除~ - 其他 → 标准搜索
§示例
use xore_search::query::{QueryAnalyzer, QueryType};
let (qtype, query) = QueryAnalyzer::analyze("config*");
assert_eq!(qtype, QueryType::Prefix);
assert_eq!(query, "config");
let (qtype, query) = QueryAnalyzer::analyze("~databse");
assert_eq!(qtype, QueryType::Fuzzy);
assert_eq!(query, "databse");
let (qtype, query) = QueryAnalyzer::analyze("error");
assert_eq!(qtype, QueryType::Standard);
assert_eq!(query, "error");Sourcepub fn detect_type(query_str: &str) -> QueryType
pub fn detect_type(query_str: &str) -> QueryType
检测查询类型(不返回清理后的查询)
Auto Trait Implementations§
impl Freeze for QueryAnalyzer
impl RefUnwindSafe for QueryAnalyzer
impl Send for QueryAnalyzer
impl Sync for QueryAnalyzer
impl Unpin for QueryAnalyzer
impl UnsafeUnpin for QueryAnalyzer
impl UnwindSafe for QueryAnalyzer
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
Converts
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>
Converts
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 more