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

source

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.
source

pub fn analyzer<S>(self, analyzer: S) -> Selfwhere S: Into<Analysis>,

Specify an analyzer, either it’s built-in analyzer, custom analyzer, built-in normalizer, custom normalizer or field

source

pub fn attributes<I>(self, attributes: I) -> Selfwhere I: IntoIterator, I::Item: ToString,

Array of token attributes used to filter the output of the explain parameter.

source

pub fn explain(self, explain: bool) -> Self

If true, the response includes token attributes and additional details. Defaults to false. experimental

Trait Implementations§

source§

impl Clone for Analyze

source§

fn clone(&self) -> Analyze

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Analyze

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Analyze

source§

fn default() -> Analyze

Returns the “default value” for a type. Read more
source§

impl PartialEq<Analyze> for Analyze

source§

fn eq(&self, other: &Analyze) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Analyze

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Analyze

source§

impl StructuralEq for Analyze

source§

impl StructuralPartialEq for Analyze

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.