Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: score filter (#5645)

Nathan.fooobf087bba5d99
diff --git a/frontend/rust-lib/flowy-search/src/document/handler.rs b/frontend/rust-lib/flowy-search/src/document/handler.rs
index ffdafb8cc7..3cb499a5ce 100644
--- a/frontend/rust-lib/flowy-search/src/document/handler.rs
+++ b/frontend/rust-lib/flowy-search/src/document/handler.rs
@@ -1,4 +1,5 @@
use std::sync::Arc;
+use tracing::{trace, warn};
use flowy_error::FlowyResult;
use flowy_folder::{manager::FolderManager, ViewLayout};
@@ -52,6 +53,7 @@ impl SearchHandler for DocumentSearchHandler {
.cloud_service
.document_search(&workspace_id, query)
.await?;
+ trace!("[Search] remote search results: {:?}", results);
// Grab all views from folder cache
// Notice that `get_all_view_pb` returns Views that don't include trashed and private views
@@ -86,9 +88,12 @@ impl SearchHandler for DocumentSearchHandler {
workspace_id: result.workspace_id,
preview: result.preview,
});
+ } else {
+ warn!("No view found for search result: {:?}", result);
}
}
+ trace!("[Search] showing results: {:?}", search_results);
Ok(search_results)
}
diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/search.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/search.rs
index c0bf6e2dea..552a94068a 100644
--- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/search.rs
+++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/search.rs
@@ -11,7 +11,8 @@ pub(crate) struct AFCloudSearchCloudServiceImpl<T> {
// The limit of what the score should be for results, used to
// filter out irrelevant results.
-const SCORE_LIMIT: f64 = 0.8;
+// https://community.openai.com/t/rule-of-thumb-cosine-similarity-thresholds/693670/5
+const SCORE_LIMIT: f64 = 0.3;
const DEFAULT_PREVIEW: u32 = 80;
#[async_trait]
@@ -32,7 +33,7 @@ where
// Filter out irrelevant results
let result = result
.into_iter()
- .filter(|r| r.score < SCORE_LIMIT)
+ .filter(|r| r.score > SCORE_LIMIT)
.collect();
Ok(result)