Struct elasticsearch_dsl::analyze::Analyze
source · [−]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
sourceimpl Analyze
impl Analyze
sourcepub fn new<S>(text: S) -> Self where
S: Into<StringOrVecString>,
pub fn new<S>(text: S) -> Self where
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 where
S: Into<Analysis>,
pub fn analyzer<S>(self, analyzer: S) -> Self where
S: Into<Analysis>,
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 where
I: IntoIterator,
I::Item: Into<String>,
pub fn attributes<I>(self, attributes: I) -> Self where
I: IntoIterator,
I::Item: Into<String>,
Array of token attributes used to filter the output of the explain parameter.
Trait Implementations
impl StructuralPartialEq for Analyze
Auto Trait Implementations
impl RefUnwindSafe for Analyze
impl Send for Analyze
impl Sync for Analyze
impl Unpin for Analyze
impl UnwindSafe for Analyze
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more