Struct 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§

Source§

impl Analyze

Source

pub fn new<S>(text: S) -> Self

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) -> Self
where 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) -> Self
where 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 for Analyze

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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 StructuralPartialEq for Analyze

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.