mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: score filter (#5645)
* fix: score filter * chore: update score limit
This commit is contained in:
parent
605a53f2ae
commit
bf087bba5d
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user