Struct UnifiedHighlighter

Source
pub struct UnifiedHighlighter { /* private fields */ }
Expand description

The unified highlighter uses the Lucene Unified Highlighter. This highlighter breaks the text into sentences and uses the BM25 algorithm to score individual sentences as if they were documents in the corpus. It also supports accurate phrase and multi-term (fuzzy, prefix, regex) highlighting. This is the default highlighter.

https://www.elastic.co/guide/en/elasticsearch/reference/current/highlighting.html#unified-highlighter

Implementations§

Source§

impl UnifiedHighlighter

Source

pub fn new() -> Self

Creates a new UnifiedHighlighter instance

Source

pub fn boundary_chars<T>(self, boundary_chars: T) -> Self
where T: ToString,

A string that contains each boundary character. Defaults to .,!? \t\n.

Source

pub fn boundary_max_scan(self, boundary_max_scan: u32) -> Self

How far to scan for boundary characters. Defaults to 20.

Source

pub fn encoder(self, encoder: Encoder) -> Self

Indicates if the snippet should be HTML encoded.

Source

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

Highlight based on the source even if the field is stored separately. Defaults to false.

Source

pub fn fragment_size(self, fragment_size: u32) -> Self

The size of the highlighted fragment in characters. Defaults to 100.

Source

pub fn highlight_query<T>(self, highlight_query: T) -> Self
where T: Into<Query>,

Highlight matches for a query other than the search query. This is especially useful if you use a rescore query because those are not taken into account by highlighting by default.

Warning
Elasticsearch does not validate that highlight_query contains the search query in any way so it is possible to define it so legitimate query results are not highlighted. Generally, you should include the search query as part of the highlight_query.

Source

pub fn no_match_size(self, no_match_size: u32) -> Self

The amount of text you want to return from the beginning of the field if there are no matching fragments to highlight. Defaults to 0 (nothing is returned).

Source

pub fn number_of_fragments(self, number_of_fragments: u32) -> Self

The maximum number of fragments to return. If the number of fragments is set to 0, no fragments are returned. Instead, the entire field contents are highlighted and returned. This can be handy when you need to highlight short texts such as a title or address, but fragmentation is not required. If number_of_fragments is 0, fragment_size is ignored. Defaults to 5.

Source

pub fn order(self, order: Order) -> Self

Sorts highlighted fragments by score when set to score. By default, fragments will be output in the order they appear in the field (order: none). Setting this option to score will output the most relevant fragments first. Each highlighter applies its own logic to compute relevancy scores. See the document How highlighters work internally for more details how different highlighters find the best fragments.

Source

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

By default, only fields that contains a query match are highlighted. Set require_field_match to false to highlight all fields. Defaults to true.

Source

pub fn tags<T>(self, tags: T) -> Self
where T: Into<Tags>,

Set to styled to use the built-in tag schema or use custom tags

Source

pub fn boundary_scanner(self, boundary_scanner: UnifiedBoundaryScanner) -> Self

Specifies how to break the highlighted fragments.

Trait Implementations§

Source§

impl Clone for UnifiedHighlighter

Source§

fn clone(&self) -> UnifiedHighlighter

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 UnifiedHighlighter

Source§

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

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

impl Default for UnifiedHighlighter

Source§

fn default() -> Self

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

impl From<UnifiedHighlighter> for Highlighter

Source§

fn from(highlighter: UnifiedHighlighter) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for UnifiedHighlighter

Source§

fn eq(&self, other: &UnifiedHighlighter) -> 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 UnifiedHighlighter

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

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.