pub struct Analyze { /* private fields */ }
Expand description
Performs analysis on a text string and returns the resulting tokens.
The basic analyze
:
To analyze
with custom analyzer:
let custom_analyzer = CustomAnalyzer::new("whitespace")
.filter([
StringOrObject::String("lowercase".to_string()),
StringOrObject::Object(json!({"type": "stop", "stopwords": ["a", "is", "this"]})),
]);
let test = Analyze::new(["test this text", "and this one please"])
.analyzer(custom_analyzer)
.explain(true)
.attributes(["attributes"]);
To analyze
custom normalizer:
let custom_normalizer = CustomNormalizer::new()
.char_filter([
json!({ "type": "mapping", "mappings": ["٠ => 0", "١ => 1", "٢ => 2"] }),
])
.filter(["snowball"]);
let test = Analyze::new(["test this text", "and this one please"])
.analyzer(custom_normalizer)
.explain(true)
.attributes(["attributes"]);
Implementations§
Source§impl Analyze
impl Analyze
Sourcepub fn new<S>(text: S) -> Selfwhere
S: Into<StringOrVecString>,
pub fn new<S>(text: S) -> Selfwhere
S: Into<StringOrVecString>,
Creates an instance of Analyze
text
- Text to analyze. If an array of strings is provided, it is analyzed as a multi-value field.
Sourcepub fn analyzer<S>(self, analyzer: S) -> Self
pub fn analyzer<S>(self, analyzer: S) -> Self
Specify an analyzer, either it’s built-in analyzer, custom analyzer, built-in normalizer, custom normalizer or field
Sourcepub fn attributes<I>(self, attributes: I) -> Self
pub fn attributes<I>(self, attributes: I) -> Self
Array of token attributes used to filter the output of the explain parameter.
Trait Implementations§
impl Eq for Analyze
impl StructuralPartialEq for Analyze
Auto Trait Implementations§
impl Freeze for Analyze
impl RefUnwindSafe for Analyze
impl Send for Analyze
impl Sync for Analyze
impl Unpin for Analyze
impl UnwindSafe for Analyze
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