Struct elasticsearch_dsl::search::highlight::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
towith_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 theunified
highlighter.
Implementations
sourceimpl FastVectorHighlighter
impl FastVectorHighlighter
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new FastVectorHighlighter instance
sourcepub fn boundary_chars(self, boundary_chars: impl Into<String>) -> Self
pub fn boundary_chars(self, boundary_chars: impl Into<String>) -> Self
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(self, highlight_query: impl Into<Query>) -> Self
pub fn highlight_query(self, highlight_query: impl Into<Query>) -> 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 boundary_scanner(self, boundary_scanner: FvhBoundaryScanner) -> Self
pub fn boundary_scanner(self, boundary_scanner: FvhBoundaryScanner) -> Self
Specifies how to break the highlighted fragments.
sourcepub fn fragment_offset(self, fragment_offset: u32) -> Self
pub fn fragment_offset(self, fragment_offset: u32) -> Self
Controls the margin from which you want to start highlighting.
sourcepub fn matched_fields(self, matched_fields: impl Into<MatchedFields>) -> Self
pub fn matched_fields(self, matched_fields: impl Into<MatchedFields>) -> Self
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.
sourcepub fn phrase_limit(self, phrase_limit: u32) -> Self
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
sourceimpl Clone for FastVectorHighlighter
impl Clone for FastVectorHighlighter
sourcefn clone(&self) -> FastVectorHighlighter
fn clone(&self) -> FastVectorHighlighter
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for FastVectorHighlighter
impl Debug for FastVectorHighlighter
sourceimpl Default for FastVectorHighlighter
impl Default for FastVectorHighlighter
sourceimpl From<FastVectorHighlighter> for Highlighter
impl From<FastVectorHighlighter> for Highlighter
sourcefn from(highlighter: FastVectorHighlighter) -> Self
fn from(highlighter: FastVectorHighlighter) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<FastVectorHighlighter> for FastVectorHighlighter
impl PartialEq<FastVectorHighlighter> for FastVectorHighlighter
sourcefn eq(&self, other: &FastVectorHighlighter) -> bool
fn eq(&self, other: &FastVectorHighlighter) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &FastVectorHighlighter) -> bool
fn ne(&self, other: &FastVectorHighlighter) -> bool
This method tests for !=
.
sourceimpl Serialize for FastVectorHighlighter
impl Serialize for FastVectorHighlighter
impl StructuralPartialEq for FastVectorHighlighter
Auto Trait Implementations
impl RefUnwindSafe for FastVectorHighlighter
impl Send for FastVectorHighlighter
impl Sync for FastVectorHighlighter
impl Unpin for FastVectorHighlighter
impl UnwindSafe for FastVectorHighlighter
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more