pub struct DefaultHighlighter { /* private fields */ }
Expand description
Highlighting settings can be set on a global level and overridden at the field level
Implementations§
Source§impl DefaultHighlighter
impl DefaultHighlighter
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Highlighter instance
Sourcepub fn boundary_chars<T>(self, boundary_chars: T) -> Selfwhere
T: ToString,
pub fn boundary_chars<T>(self, boundary_chars: T) -> Selfwhere
T: ToString,
A string that contains each boundary character. Defaults to .,!? \t\n
.
Sourcepub fn boundary_max_scan(self, boundary_max_scan: u32) -> Self
pub fn boundary_max_scan(self, boundary_max_scan: u32) -> Self
How far to scan for boundary characters. Defaults to 20
.
Sourcepub fn encoder(self, encoder: Encoder) -> Self
pub fn encoder(self, encoder: Encoder) -> Self
Indicates if the snippet should be HTML encoded.
Sourcepub fn force_source(self, force_source: bool) -> Self
pub fn force_source(self, force_source: bool) -> Self
Highlight based on the source even if the field is stored separately. Defaults to false
.
Sourcepub fn fragment_size(self, fragment_size: u32) -> Self
pub fn fragment_size(self, fragment_size: u32) -> Self
The size of the highlighted fragment in characters. Defaults to
100
.
Sourcepub fn highlight_query<T>(self, highlight_query: T) -> Self
pub fn highlight_query<T>(self, highlight_query: T) -> Self
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 thathighlight_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 thehighlight_query
.
Sourcepub fn no_match_size(self, no_match_size: u32) -> Self
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).
Sourcepub fn number_of_fragments(self, number_of_fragments: u32) -> Self
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
.
Sourcepub fn order(self, order: Order) -> Self
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.
Sourcepub fn require_field_match(self, require_field_match: bool) -> Self
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
.
Set to styled
to use the built-in tag schema or use custom tags
Sourcepub fn fvh(self) -> FastVectorHighlighter
pub fn fvh(self) -> FastVectorHighlighter
Converts Highlighter to specific highlighter
Sourcepub fn plain(self) -> PlainHighlighter
pub fn plain(self) -> PlainHighlighter
Converts Highlighter to specific highlighter
Sourcepub fn unified(self) -> UnifiedHighlighter
pub fn unified(self) -> UnifiedHighlighter
Converts Highlighter to specific highlighter
Trait Implementations§
Source§impl Clone for DefaultHighlighter
impl Clone for DefaultHighlighter
Source§fn clone(&self) -> DefaultHighlighter
fn clone(&self) -> DefaultHighlighter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more