mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 11:57:07 +02:00
Add format option structure
This commit is contained in:
parent
011f8210ed
commit
827cedcd15
4 changed files with 85 additions and 91 deletions
|
@ -25,8 +25,8 @@ use milli::update::{
|
|||
ClearDocuments, IndexDocumentsConfig, IndexDocumentsMethod, IndexerConfig, Setting,
|
||||
};
|
||||
use milli::{
|
||||
obkv_to_json, CompressionType, Filter as MilliFilter, FilterCondition, Index, MatcherBuilder,
|
||||
SearchResult, SortError,
|
||||
obkv_to_json, CompressionType, Filter as MilliFilter, FilterCondition, FormatOptions, Index,
|
||||
MatcherBuilder, SearchResult, SortError,
|
||||
};
|
||||
use once_cell::sync::OnceCell;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -162,7 +162,9 @@ impl<'a, A: AsRef<[u8]>> Highlighter<'a, A> {
|
|||
let analyzed: Vec<_> = analyzed.tokens().collect();
|
||||
let mut matcher = matcher_builder.build(&analyzed[..], &old_string);
|
||||
|
||||
Value::String(matcher.format(true, true).to_string())
|
||||
let format_options = FormatOptions { highlight: true, crop: Some(10) };
|
||||
|
||||
Value::String(matcher.format(format_options).to_string())
|
||||
}
|
||||
Value::Array(values) => Value::Array(
|
||||
values.into_iter().map(|v| self.highlight_value(v, matcher_builder)).collect(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue