Struct FastVectorHighlighter

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

The fvh highlighter uses the Lucene Fast Vector highlighter. This highlighter can be used on fields with term_vector set to with_positions_offsets in the mapping. The fast vector highlighter:

  • Can be customized with a boundary_scanner.
  • Requires setting term_vector to with_positions_offsets which increases the size of the index
  • Can combine matches from multiple fields into one result. See matched_fields
  • Can assign different weights to matches at different positions allowing for things like phrase matches being sorted above term matches when highlighting a Boosting Query that boosts phrase matches over term matches

Warning
The fvh highlighter does not support span queries. If you need support for span queries, try an alternative highlighter, such as the unified highlighter.

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

Implementations§

Source§

impl FastVectorHighlighter

Source

pub fn new() -> Self

Creates a new FastVectorHighlighter 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: FvhBoundaryScanner) -> Self

Specifies how to break the highlighted fragments.

Source

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

Controls the margin from which you want to start highlighting.

Source

pub fn matched_fields<T>(self, matched_fields: T) -> Self
where T: Into<MatchedFields>,

Combine matches on multiple fields to highlight a single field. This is most intuitive for multi-fields that analyze the same string in different ways. All matched_fields must have term_vector set to with_positions_offsets, but only the field to which the matches are combined is loaded so only that field benefits from having store set to yes.

Source

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

Controls the number of matching phrases in a document that are considered. Prevents the highlighter from analyzing too many phrases and consuming too much memory. When using matched_fields, phrase_limit phrases per matched field are considered. Raising the limit increases query time and consumes more memory. Defaults to 256.

Trait Implementations§

Source§

impl Clone for FastVectorHighlighter

Source§

fn clone(&self) -> FastVectorHighlighter

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 FastVectorHighlighter

Source§

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

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

impl Default for FastVectorHighlighter

Source§

fn default() -> Self

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

impl From<FastVectorHighlighter> for Highlighter

Source§

fn from(highlighter: FastVectorHighlighter) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for FastVectorHighlighter

Source§

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

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 FastVectorHighlighter

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.