mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
add SearchHit structure
This commit is contained in:
parent
09f13823f4
commit
526a05565e
@ -35,10 +35,18 @@ pub struct SearchQuery {
|
|||||||
pub facet_distributions: Option<Vec<String>>,
|
pub facet_distributions: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
pub struct SearchHit {
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub document: Map<String, Value>,
|
||||||
|
#[serde(rename = "_formatted", skip_serializing_if = "Map::is_empty")]
|
||||||
|
pub formatted: Map<String, Value>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct SearchResult {
|
pub struct SearchResult {
|
||||||
pub hits: Vec<Map<String, Value>>,
|
pub hits: Vec<SearchHit>,
|
||||||
pub nb_hits: u64,
|
pub nb_hits: u64,
|
||||||
pub exhaustive_nb_hits: bool,
|
pub exhaustive_nb_hits: bool,
|
||||||
pub query: String,
|
pub query: String,
|
||||||
@ -90,7 +98,11 @@ impl Index {
|
|||||||
if let Some(ref attributes_to_highlight) = query.attributes_to_highlight {
|
if let Some(ref attributes_to_highlight) = query.attributes_to_highlight {
|
||||||
highlighter.highlight_record(&mut object, &matching_words, attributes_to_highlight);
|
highlighter.highlight_record(&mut object, &matching_words, attributes_to_highlight);
|
||||||
}
|
}
|
||||||
documents.push(object);
|
let hit = SearchHit {
|
||||||
|
document: object,
|
||||||
|
formatted: Map::new(),
|
||||||
|
};
|
||||||
|
documents.push(hit);
|
||||||
}
|
}
|
||||||
|
|
||||||
let nb_hits = candidates.len();
|
let nb_hits = candidates.len();
|
||||||
|
Loading…
Reference in New Issue
Block a user