Skip to content

Commit

Permalink
fix: Fix #148
Browse files Browse the repository at this point in the history
  • Loading branch information
Losses committed Dec 3, 2024
1 parent 2fb899c commit 6dd196c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions database/src/actions/recommendation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::num::NonZeroUsize;
use anyhow::{bail, Context, Result};
use arroy::distances::Euclidean;
use arroy::{Reader, Writer};
use log::error;
use rand::rngs::StdRng;
use rand::SeedableRng;
use rust_decimal::prelude::ToPrimitive;
Expand Down Expand Up @@ -71,12 +72,20 @@ pub fn get_recommendation_by_parameter(

let results = reader
.nns_by_vector(&rtxn, &feature_vector, n, Some(search_k), None)
.with_context(|| "Failed to get recommendation by parameter")?;

if results.is_empty() {
bail!("No results found for the given parameter")
} else {
Ok(results)
.with_context(|| "Failed to get recommendation by parameter");

match results {
Ok(results) => {
if results.is_empty() {
bail!("No results found for the given parameter")
} else {
Ok(results)
}
}
Err(e) => {
error!("{:#?}", e);
Ok(vec![])
}
}
}

Expand Down

0 comments on commit 6dd196c

Please sign in to comment.