Add TODOs

This commit is contained in:
ManyTheFish 2023-12-13 11:46:09 +01:00 committed by Louis Dureuil
parent a4536b1381
commit 9991152bbe
No known key found for this signature in database
3 changed files with 6 additions and 0 deletions

View File

@ -90,6 +90,7 @@ pub struct SearchQuery {
#[derive(Debug, Clone, Default, PartialEq, Deserr)] #[derive(Debug, Clone, Default, PartialEq, Deserr)]
#[deserr(error = DeserrJsonError<InvalidHybridQuery>, rename_all = camelCase, deny_unknown_fields)] #[deserr(error = DeserrJsonError<InvalidHybridQuery>, rename_all = camelCase, deny_unknown_fields)]
pub struct HybridQuery { pub struct HybridQuery {
/// TODO validate that sementic ratio is between 0.0 and 1,0
#[deserr(default, error = DeserrJsonError<InvalidSemanticRatio>, default = DEFAULT_SEMANTIC_RATIO())] #[deserr(default, error = DeserrJsonError<InvalidSemanticRatio>, default = DEFAULT_SEMANTIC_RATIO())]
pub semantic_ratio: f32, pub semantic_ratio: f32,
#[deserr(default, error = DeserrJsonError<InvalidEmbedder>, default)] #[deserr(default, error = DeserrJsonError<InvalidEmbedder>, default)]
@ -452,6 +453,9 @@ pub fn perform_search(
let (search, is_finite_pagination, max_total_hits, offset) = let (search, is_finite_pagination, max_total_hits, offset) =
prepare_search(index, &rtxn, &query, features)?; prepare_search(index, &rtxn, &query, features)?;
/// TODO: Change if-cond to query.hybrid.is_some
/// + < 1.0 or remove q
/// + > 0.0 or remove vector
let milli::SearchResult { documents_ids, matching_words, candidates, document_scores, .. } = let milli::SearchResult { documents_ids, matching_words, candidates, document_scores, .. } =
if query.q.is_some() && query.vector.is_some() { if query.q.is_some() && query.vector.is_some() {
search.execute_hybrid()? search.execute_hybrid()?

View File

@ -252,6 +252,7 @@ impl<'a> Search<'a> {
// can unwrap because we returned already if there was no vector query // can unwrap because we returned already if there was no vector query
self.vector_results_for_keyword(search.vector.as_ref().unwrap(), &keyword_results)?; self.vector_results_for_keyword(search.vector.as_ref().unwrap(), &keyword_results)?;
/// TODO apply sementic ratio
let keyword_results = let keyword_results =
CombinedSearchResult::new(keyword_results, vector_results_for_keyword); CombinedSearchResult::new(keyword_results, vector_results_for_keyword);
let vector_results = CombinedSearchResult::new(vector_results, keyword_results_for_vector); let vector_results = CombinedSearchResult::new(vector_results, keyword_results_for_vector);

View File

@ -50,6 +50,7 @@ pub struct Search<'a> {
scoring_strategy: ScoringStrategy, scoring_strategy: ScoringStrategy,
words_limit: usize, words_limit: usize,
exhaustive_number_hits: bool, exhaustive_number_hits: bool,
/// TODO: Add semantic ratio or pass it directly to execute_hybrid()
rtxn: &'a heed::RoTxn<'a>, rtxn: &'a heed::RoTxn<'a>,
index: &'a Index, index: &'a Index,
distribution_shift: Option<DistributionShift>, distribution_shift: Option<DistributionShift>,