mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-29 16:24:26 +01:00
search: introduce "search_from_kind"
This commit is contained in:
parent
edab4e75b0
commit
2123d76089
@ -866,15 +866,7 @@ pub fn perform_search(
|
|||||||
used_negative_operator,
|
used_negative_operator,
|
||||||
},
|
},
|
||||||
semantic_hit_count,
|
semantic_hit_count,
|
||||||
) = match &search_kind {
|
) = search_from_kind(search_kind, search)?;
|
||||||
SearchKind::KeywordOnly => (search.execute()?, None),
|
|
||||||
SearchKind::SemanticOnly { .. } => {
|
|
||||||
let results = search.execute()?;
|
|
||||||
let semantic_hit_count = results.document_scores.len() as u32;
|
|
||||||
(results, Some(semantic_hit_count))
|
|
||||||
}
|
|
||||||
SearchKind::Hybrid { semantic_ratio, .. } => search.execute_hybrid(*semantic_ratio)?,
|
|
||||||
};
|
|
||||||
|
|
||||||
let SearchQuery {
|
let SearchQuery {
|
||||||
q,
|
q,
|
||||||
@ -990,6 +982,22 @@ pub fn perform_search(
|
|||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn search_from_kind(
|
||||||
|
search_kind: SearchKind,
|
||||||
|
search: milli::Search<'_>,
|
||||||
|
) -> Result<(milli::SearchResult, Option<u32>), MeilisearchHttpError> {
|
||||||
|
let (milli_result, semantic_hit_count) = match &search_kind {
|
||||||
|
SearchKind::KeywordOnly => (search.execute()?, None),
|
||||||
|
SearchKind::SemanticOnly { .. } => {
|
||||||
|
let results = search.execute()?;
|
||||||
|
let semantic_hit_count = results.document_scores.len() as u32;
|
||||||
|
(results, Some(semantic_hit_count))
|
||||||
|
}
|
||||||
|
SearchKind::Hybrid { semantic_ratio, .. } => search.execute_hybrid(*semantic_ratio)?,
|
||||||
|
};
|
||||||
|
Ok((milli_result, semantic_hit_count))
|
||||||
|
}
|
||||||
|
|
||||||
struct AttributesFormat {
|
struct AttributesFormat {
|
||||||
attributes_to_retrieve: Option<BTreeSet<String>>,
|
attributes_to_retrieve: Option<BTreeSet<String>>,
|
||||||
retrieve_vectors: RetrieveVectors,
|
retrieve_vectors: RetrieveVectors,
|
||||||
|
Loading…
Reference in New Issue
Block a user