Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(search): disable recency boost on name content search (#120)

Will Hutchinsonba9c5fdb71ed
diff --git a/rust/cloud-storage/ai_tools/src/search/unified.rs b/rust/cloud-storage/ai_tools/src/search/unified.rs
index 0bc7940916..a8f1978594 100644
--- a/rust/cloud-storage/ai_tools/src/search/unified.rs
+++ b/rust/cloud-storage/ai_tools/src/search/unified.rs
@@ -215,6 +215,7 @@ impl AsyncTool<ToolServiceContext, RequestContext> for UnifiedSearch {
search_on: self.request.search_on,
collapse: Some(false), // collapse=true will return one result per opensearch document
include: self.request.include.clone(),
+ disable_recency: self.request.disable_recency,
};
tracing::info!(search_request=?search_request, "Unified search request");
diff --git a/rust/cloud-storage/models_search/src/channel.rs b/rust/cloud-storage/models_search/src/channel.rs
index ec4aeb4a70..92a3815632 100644
--- a/rust/cloud-storage/models_search/src/channel.rs
+++ b/rust/cloud-storage/models_search/src/channel.rs
@@ -99,6 +99,10 @@ pub struct ChannelSearchRequest {
pub terms: Option<Vec<String>>,
/// The match type to use when searching
pub match_type: MatchType,
+ /// If search_on is set to NameContent, you can disable the recency filter
+ /// by setting to true.
+ #[serde(default)]
+ pub disable_recency: bool,
/// Search filters for channels
#[serde(flatten)]
pub filters: Option<ChannelFilters>,
diff --git a/rust/cloud-storage/models_search/src/channel/test.rs b/rust/cloud-storage/models_search/src/channel/test.rs
index 8ee94174ee..147eee8a6b 100644
--- a/rust/cloud-storage/models_search/src/channel/test.rs
+++ b/rust/cloud-storage/models_search/src/channel/test.rs
@@ -15,10 +15,11 @@ fn test_channel_search_request_json_serialization() {
}),
search_on: SearchOn::Content,
collapse: None,
+ disable_recency: false,
};
let json = serde_json::to_string(&request).expect("Failed to serialize to JSON");
- let expected = r#"{"query":"test query","terms":["term1","term2"],"match_type":"exact","thread_ids":["thread1","thread2"],"mentions":["@user1","@user2"],"org_id":12345,"search_on":"content"}"#;
+ let expected = r#"{"query":"test query","terms":["term1","term2"],"match_type":"exact","disable_recency":false,"thread_ids":["thread1","thread2"],"mentions":["@user1","@user2"],"org_id":12345,"search_on":"content"}"#;
assert_eq!(json, expected);
}
@@ -92,6 +93,7 @@ fn test_channel_search_request_round_trip() {
}),
search_on: SearchOn::Content,
collapse: None,
+ disable_recency: false,
};
let json = serde_json::to_string(&original).expect("Failed to serialize");
diff --git a/rust/cloud-storage/models_search/src/chat.rs b/rust/cloud-storage/models_search/src/chat.rs
index 9f8e9f087e..e8fa52cd0a 100644
--- a/rust/cloud-storage/models_search/src/chat.rs
+++ b/rust/cloud-storage/models_search/src/chat.rs
@@ -67,6 +67,10 @@ pub struct ChatSearchRequest {
pub terms: Option<Vec<String>>,
/// The match type to use when searching
pub match_type: MatchType,
+ /// If search_on is set to NameContent, you can disable the recency filter
+ /// by setting to true.
+ #[serde(default)]
+ pub disable_recency: bool,
/// Search filters for chat
#[serde(flatten)]
pub filters: Option<ChatFilters>,
diff --git a/rust/cloud-storage/models_search/src/chat/test.rs b/rust/cloud-storage/models_search/src/chat/test.rs
index 623393a7a1..3745186872 100644
--- a/rust/cloud-storage/models_search/src/chat/test.rs
+++ b/rust/cloud-storage/models_search/src/chat/test.rs
@@ -15,10 +15,11 @@ fn test_chat_search_request_json_serialization() {
}),
search_on: SearchOn::Content,
collapse: None,
+ disable_recency: false,
};
let json = serde_json::to_string(&request).expect("Failed to serialize to JSON");
- let expected = r#"{"query":"test query","terms":["term1","term2"],"match_type":"exact","role":["user","system"],"search_on":"content"}"#;
+ let expected = r#"{"query":"test query","terms":["term1","term2"],"match_type":"exact","disable_recency":false,"role":["user","system"],"search_on":"content"}"#;
assert_eq!(json, expected);
}
@@ -87,6 +88,7 @@ fn test_chat_search_request_round_trip() {
}),
search_on: SearchOn::Content,
collapse: None,
+ disable_recency: false,
};
let json = serde_json::to_string(&original).expect("Failed to serialize");
diff --git a/rust/cloud-storage/models_search/src/document.rs b/rust/cloud-storage/models_search/src/document.rs
index fb61ae74b7..4c364cc3b0 100644
--- a/rust/cloud-storage/models_search/src/document.rs
+++ b/rust/cloud-storage/models_search/src/document.rs
@@ -147,6 +147,10 @@ pub struct DocumentSearchRequest {
pub terms: Option<Vec<String>>,
/// The match type to use when searching
pub match_type: MatchType,
+ /// If search_on is set to NameContent, you can disable the recency filter
+ /// by setting to true.
+ #[serde(default)]
+ pub disable_recency: bool,
/// Search filters for documents
#[serde(flatten)]
pub filters: Option<DocumentFilters>,
diff --git a/rust/cloud-storage/models_search/src/document/test.rs b/rust/cloud-storage/models_search/src/document/test.rs
index a513f34cad..73e5082fc6 100644
--- a/rust/cloud-storage/models_search/src/document/test.rs
+++ b/rust/cloud-storage/models_search/src/document/test.rs
@@ -15,10 +15,11 @@ fn test_document_search_request_json_serialization() {
}),
search_on: SearchOn::Content,
collapse: None,
+ disable_recency: false,
};
let json = serde_json::to_string(&request).expect("Failed to serialize to JSON");
- let expected = r#"{"query":"test query","terms":["term1","term2"],"match_type":"exact","file_types":["pdf","docx"],"search_on":"content"}"#;
+ let expected = r#"{"query":"test query","terms":["term1","term2"],"match_type":"exact","disable_recency":false,"file_types":["pdf","docx"],"search_on":"content"}"#;
assert_eq!(json, expected);
}
@@ -87,6 +88,7 @@ fn test_document_search_request_round_trip() {
}),
search_on: SearchOn::Content,
collapse: None,
+ disable_recency: false,
};
let json = serde_json::to_string(&original).expect("Failed to serialize");
diff --git a/rust/cloud-storage/models_search/src/email.rs b/rust/cloud-storage/models_search/src/email.rs
index 5344fdab0e..d20b98cf80 100644
--- a/rust/cloud-storage/models_search/src/email.rs
+++ b/rust/cloud-storage/models_search/src/email.rs
@@ -93,6 +93,10 @@ pub struct EmailSearchRequest {
pub terms: Option<Vec<String>>,
/// The match type to use when searching
pub match_type: MatchType,
+ /// If search_on is set to NameContent, you can disable the recency filter
+ /// by setting to true.
+ #[serde(default)]
+ pub disable_recency: bool,
/// Search filters for email
#[serde(flatten)]
pub filters: Option<EmailFilters>,
diff --git a/rust/cloud-storage/models_search/src/email/test.rs b/rust/cloud-storage/models_search/src/email/test.rs
index cc353de786..10f36b4747 100644
--- a/rust/cloud-storage/models_search/src/email/test.rs
+++ b/rust/cloud-storage/models_search/src/email/test.rs
@@ -15,10 +15,11 @@ fn test_email_search_request_json_serialization() {
}),
search_on: SearchOn::Content,
collapse: None,
+ disable_recency: false,
};
let json = serde_json::to_string(&request).expect("Failed to serialize to JSON");
- let expected = r#"{"query":"test query","terms":["term1","term2"],"match_type":"exact","senders":["[email protected]"],"cc":["[email protected]"],"bcc":["[email protected]"],"search_on":"content"}"#;
+ let expected = r#"{"query":"test query","terms":["term1","term2"],"match_type":"exact","disable_recency":false,"senders":["[email protected]"],"cc":["[email protected]"],"bcc":["[email protected]"],"search_on":"content"}"#;
assert_eq!(json, expected);
}
@@ -98,6 +99,7 @@ fn test_email_search_request_round_trip() {
}),
search_on: SearchOn::Content,
collapse: None,
+ disable_recency: false,
};
let json = serde_json::to_string(&original).expect("Failed to serialize");
diff --git a/rust/cloud-storage/models_search/src/project.rs b/rust/cloud-storage/models_search/src/project.rs
index 54fb2f39e2..e4446ba6f7 100644
--- a/rust/cloud-storage/models_search/src/project.rs
+++ b/rust/cloud-storage/models_search/src/project.rs
@@ -73,6 +73,10 @@ pub struct ProjectSearchRequest {
pub terms: Option<Vec<String>>,
/// The match type to use when searching
pub match_type: MatchType,
+ /// If search_on is set to NameContent, you can disable the recency filter
+ /// by setting to true.
+ #[serde(default)]
+ pub disable_recency: bool,
/// Search filters for chat
#[serde(flatten)]
pub filters: Option<ProjectFilters>,
diff --git a/rust/cloud-storage/models_search/src/unified.rs b/rust/cloud-storage/models_search/src/unified.rs
index dc9687c5f2..7cd3c16749 100644
--- a/rust/cloud-storage/models_search/src/unified.rs
+++ b/rust/cloud-storage/models_search/src/unified.rs
@@ -28,29 +28,30 @@ pub enum UnifiedSearchIndex {
pub struct UnifiedSearchRequest {
#[schemars(skip)]
pub query: Option<String>,
- #[schemars(
- description = "Multiple distinct search terms as separate strings. Use this for keyword-based searches where you want to find content containing any of these terms. Each term must be at least 3 characters (shorter terms are automatically filtered out). Examples: ['machine', 'learning', 'algorithms'], ['project', 'status', 'update']. `null` this field if searching without text terms to search all. This field matches query string against both name and content."
- )]
+
+ /// Multiple distinct search terms as separate strings. Use this for keyword-based searches where you want to find content containing any of these terms. Each term must be at least 3 characters (shorter terms are automatically filtered out). Examples: ['machine', 'learning', 'algorithms'], ['project', 'status', 'update']. `null` this field if searching without text terms to search all. This field matches query string against both name and content.
pub terms: Option<Vec<String>>,
- #[schemars(
- description = "How to match the search terms. 'exact' for precise case-sensitive phrase matches, 'partial' for prefix/partial matches. REQUIRED field."
- )]
+
+ /// How to match the search terms. 'exact' for precise case-sensitive phrase matches, 'partial' for prefix/partial matches. REQUIRED field.
pub match_type: MatchType,
- #[schemars(
- description = "Search filters for various kinds of items. Set the entire filters property as `null` if you do not have specific filters for a given type, e.g. bcc for email filters."
- )]
+
+ /// If search_on is set to NameContent, you can disable the recency filter
+ /// by setting to true.
+ #[serde(default)]
+ #[schemars(skip)]
+ pub disable_recency: bool,
+
+ /// Search filters for various kinds of items. Set the entire filters property as `null` if you do not have specific filters for a given type, e.g. bcc for email filters.
pub filters: Option<UnifiedSearchFilters>,
- #[schemars(
- description = "Fields to search on (Name, Content, NameContent). Defaults to Content"
- )]
+
+ /// Fields to search on (Name, Content, NameContent). Defaults to Content
#[serde(default)]
pub search_on: SearchOn,
+
#[schemars(skip)]
pub collapse: Option<bool>,
- #[schemars(
- description = "Include specific entity types from search. If empty, all entity types will be searched over. If you are unsure which types to search, use an empty array to search all."
- )]
+ /// Include specific entity types from search. If empty, all entity types will be searched over. If you are unsure which types to search, use an empty array to search all.
#[serde(default)]
pub include: Vec<UnifiedSearchIndex>,
}
@@ -59,15 +60,15 @@ pub struct UnifiedSearchRequest {
// None means do not search this entity, Some(_::default()) means search all for this entity
#[derive(Debug, Serialize, Deserialize, ToSchema, Clone, JsonSchema)]
pub struct UnifiedSearchFilters {
- #[schemars(description = "Document filters. `null` to not filter documents searched over.")]
+ /// Document filters. `null` to not filter documents searched over.
pub document: Option<DocumentFilters>,
- #[schemars(description = "Chat filters. `null` to not filter chats searched over.")]
+ /// Chat filters. `null` to not filter chats searched over.
pub chat: Option<ChatFilters>,
- #[schemars(description = "Email filters. `null` to not filter emails searched over.")]
+ /// Email filters. `null` to not filter emails searched over.
pub email: Option<EmailFilters>,
- #[schemars(description = "Channel filters. `null` to not filter channels searched over.")]
+ /// Channel filters. `null` to not filter channels searched over.
pub channel: Option<ChannelFilters>,
- #[schemars(description = "Project filters. `null` to not filter projects searched over.")]
+ /// Project filters. `null` to not filter projects searched over.
pub project: Option<ProjectFilters>,
}
diff --git a/rust/cloud-storage/opensearch_client/examples/query_document.rs b/rust/cloud-storage/opensearch_client/examples/query_document.rs
index 2ed9a687ae..23ba07d9a0 100644
--- a/rust/cloud-storage/opensearch_client/examples/query_document.rs
+++ b/rust/cloud-storage/opensearch_client/examples/query_document.rs
@@ -21,6 +21,7 @@ async fn main() -> anyhow::Result<()> {
search_on: SearchOn::Content,
ids_only: false,
collapse: false,
+ disable_recency: false,
})
.await?;
diff --git a/rust/cloud-storage/opensearch_client/src/search/builder.rs b/rust/cloud-storage/opensearch_client/src/search/builder.rs
index d34423965d..b7b593817f 100644
--- a/rust/cloud-storage/opensearch_client/src/search/builder.rs
+++ b/rust/cloud-storage/opensearch_client/src/search/builder.rs
@@ -103,6 +103,9 @@ pub struct SearchQueryBuilder<T: SearchQueryConfig> {
pub ids_only: bool,
/// The ids to search for defaults to an empty vector
pub ids: Vec<String>,
+ /// If true, disable the recency filter.
+ /// This only applies to the NameContent search_on
+ pub disable_recency: bool,
_phantom: std::marker::PhantomData<T>,
}
@@ -119,6 +122,7 @@ impl<T: SearchQueryConfig> SearchQueryBuilder<T> {
collapse: false,
ids_only: false,
ids: Vec::new(),
+ disable_recency: false,
_phantom: std::marker::PhantomData,
}
}
@@ -163,6 +167,11 @@ impl<T: SearchQueryConfig> SearchQueryBuilder<T> {
self
}
+ pub fn disable_recency(mut self, disable_recency: bool) -> Self {
+ self.disable_recency = disable_recency;
+ self
+ }
+
/// Builds the core bool query which contains all core "should" and "must" clauses
pub fn build_bool_query(&self) -> Result<BoolQueryBuilder> {
let mut bool_query = BoolQueryBuilder::new();
@@ -247,31 +256,35 @@ impl<T: SearchQueryConfig> SearchQueryBuilder<T> {
let built_query: QueryType = match self.search_on {
SearchOn::Name | SearchOn::Content => query_object.into(),
SearchOn::NameContent => {
- let mut function_score_query = FunctionScoreQueryBuilder::new();
-
- function_score_query.query(query_object.into());
-
- function_score_query.function(ScoreFunction {
- function: ScoreFunctionType::Gauss(DecayFunction {
- field: "updated_at_seconds".to_string(),
- origin: Some("now".into()),
- scale: "21d".to_string(),
- offset: Some("3d".to_string()),
- decay: Some(0.5),
- }),
- filter: None,
- weight: Some(1.3),
- });
-
- function_score_query.boost_mode(BoostMode::Multiply);
- function_score_query.score_mode(ScoreMode::Multiply);
-
- function_score_query.build().into()
+ if self.disable_recency {
+ query_object.into()
+ } else {
+ let mut function_score_query = FunctionScoreQueryBuilder::new();
+
+ function_score_query.query(query_object.into());
+
+ function_score_query.function(ScoreFunction {
+ function: ScoreFunctionType::Gauss(DecayFunction {
+ field: "updated_at_seconds".to_string(),
+ origin: Some("now".into()),
+ scale: "21d".to_string(),
+ offset: Some("3d".to_string()),
+ decay: Some(0.5),
+ }),
+ filter: None,
+ weight: Some(1.3),
+ });
+
+ function_score_query.boost_mode(BoostMode::Multiply);
+ function_score_query.score_mode(ScoreMode::Multiply);
+
+ function_score_query.build().into()
+ }
}
};
// We need to add aggregration and tracking to the query if we are searching on NameContent
- if self.search_on == SearchOn::NameContent {
+ if self.search_on == SearchOn::NameContent && !self.disable_recency {
search_request.track_total_hits(true);
search_request.add_agg(
"total_uniques".to_string(),
diff --git a/rust/cloud-storage/opensearch_client/src/search/builder/test.rs b/rust/cloud-storage/opensearch_client/src/search/builder/test.rs
index a0004d925f..9f6ddd3e11 100644
--- a/rust/cloud-storage/opensearch_client/src/search/builder/test.rs
+++ b/rust/cloud-storage/opensearch_client/src/search/builder/test.rs
@@ -51,7 +51,7 @@ fn test_build_search_request() -> anyhow::Result<()> {
.collapse(true)
.ids(vec!["id1".to_string(), "id2".to_string()]);
- let result = builder.build_search_request(bool_query)?;
+ let result = builder.build_search_request(bool_query.clone())?;
let expected = serde_json::json!({
"track_total_hits": true,
@@ -118,6 +118,56 @@ fn test_build_search_request() -> anyhow::Result<()> {
assert_eq!(result.to_json(), expected);
+ let builder = SearchQueryBuilder::<TestSearchConfig>::new(vec!["test".to_string()])
+ .match_type("partial")
+ .page_size(20)
+ .page(1)
+ .user_id("user123")
+ .search_on(SearchOn::NameContent)
+ .collapse(true)
+ .disable_recency(true)
+ .ids(vec!["id1".to_string(), "id2".to_string()]);
+
+ let result = builder.build_search_request(bool_query)?;
+
+ let expected = serde_json::json!({
+ "from": 20,
+ "size": 20,
+ "collapse": {
+ "field": "test_id"
+ },
+ "sort": [
+ {
+ "_score": "desc"
+ },
+ {
+ "test_id": "asc"
+ }
+ ],
+ "highlight": {
+ "require_field_match": false,
+ "fields": {
+ "content": {
+ "type": "unified",
+ "number_of_fragments": 1,
+ "pre_tags": ["<macro_em>"],
+ "post_tags": ["</macro_em>"],
+ },
+ "test_title": {
+ "type": "unified",
+ "number_of_fragments": 1,
+ "pre_tags": ["<macro_em>"],
+ "post_tags": ["</macro_em>"],
+ }
+ }
+ },
+ "query": {
+ "bool": {}
+ }
+ });
+
+ assert_eq!(result.to_json(), expected);
+
Ok(())
}
diff --git a/rust/cloud-storage/opensearch_client/src/search/channels.rs b/rust/cloud-storage/opensearch_client/src/search/channels.rs
index 73c0a3daf2..a16d2435db 100644
--- a/rust/cloud-storage/opensearch_client/src/search/channels.rs
+++ b/rust/cloud-storage/opensearch_client/src/search/channels.rs
@@ -110,6 +110,7 @@ impl ChannelMessageQueryBuilder {
fn search_on(search_on: SearchOn) -> Self;
fn ids_only(ids_only: bool) -> Self;
fn collapse(collapse: bool) -> Self;
+ fn disable_recency(disable_recency: bool) -> Self;
}
fn build_search_request(self) -> Result<SearchRequest> {
@@ -162,6 +163,7 @@ pub struct ChannelMessageSearchArgs {
pub search_on: SearchOn,
pub collapse: bool,
pub ids_only: bool,
+ pub disable_recency: bool,
}
impl ChannelMessageSearchArgs {
@@ -178,6 +180,7 @@ impl ChannelMessageSearchArgs {
.collapse(self.collapse)
.ids_only(self.ids_only)
.sender_ids(self.sender_ids)
+ .disable_recency(self.disable_recency)
.build_search_request()?
.to_json())
}
diff --git a/rust/cloud-storage/opensearch_client/src/search/chats.rs b/rust/cloud-storage/opensearch_client/src/search/chats.rs
index 11763dbfce..ca3f5272d9 100644
--- a/rust/cloud-storage/opensearch_client/src/search/chats.rs
+++ b/rust/cloud-storage/opensearch_client/src/search/chats.rs
@@ -78,6 +78,7 @@ impl ChatQueryBuilder {
fn collapse(collapse: bool) -> Self;
fn ids(ids: Vec<String>) -> Self;
fn ids_only(ids_only: bool) -> Self;
+ fn disable_recency(disable_recency: bool) -> Self;
}
pub fn role(mut self, role: Vec<String>) -> Self {
@@ -120,6 +121,7 @@ pub struct ChatSearchArgs {
pub search_on: SearchOn,
pub collapse: bool,
pub ids_only: bool,
+ pub disable_recency: bool,
}
impl ChatSearchArgs {
@@ -134,6 +136,7 @@ impl ChatSearchArgs {
.search_on(self.search_on)
.collapse(self.collapse)
.ids_only(self.ids_only)
+ .disable_recency(self.disable_recency)
.build_search_request()?
.to_json())
}
diff --git a/rust/cloud-storage/opensearch_client/src/search/documents.rs b/rust/cloud-storage/opensearch_client/src/search/documents.rs
index 05f7d771a0..2ee7a9556f 100644
--- a/rust/cloud-storage/opensearch_client/src/search/documents.rs
+++ b/rust/cloud-storage/opensearch_client/src/search/documents.rs
@@ -53,6 +53,7 @@ impl DocumentQueryBuilder {
fn collapse(collapse: bool) -> Self;
fn ids(ids: Vec<String>) -> Self;
fn ids_only(ids_only: bool) -> Self;
+ fn disable_recency(disable_recency: bool) -> Self;
}
fn build_search_request(self) -> Result<SearchRequest> {
@@ -103,6 +104,7 @@ pub struct DocumentSearchArgs {
pub search_on: SearchOn,
pub collapse: bool,
pub ids_only: bool,
+ pub disable_recency: bool,
}
impl DocumentSearchArgs {
@@ -116,6 +118,7 @@ impl DocumentSearchArgs {
.search_on(self.search_on)
.collapse(self.collapse)
.ids_only(self.ids_only)
+ .disable_recency(self.disable_recency)
.build_search_request()?
.to_json())
}
diff --git a/rust/cloud-storage/opensearch_client/src/search/emails.rs b/rust/cloud-storage/opensearch_client/src/search/emails.rs
index 28bda88930..238c0b15f7 100644
--- a/rust/cloud-storage/opensearch_client/src/search/emails.rs
+++ b/rust/cloud-storage/opensearch_client/src/search/emails.rs
@@ -73,6 +73,7 @@ impl EmailQueryBuilder {
fn collapse(collapse: bool) -> Self;
fn ids(ids: Vec<String>) -> Self;
fn ids_only(ids_only: bool) -> Self;
+ fn disable_recency(disable_recency: bool) -> Self;
}
pub fn thread_ids(mut self, thread_ids: Vec<String>) -> Self {
@@ -219,6 +220,7 @@ pub struct EmailSearchArgs {
pub search_on: SearchOn,
pub collapse: bool,
pub ids_only: bool,
+ pub disable_recency: bool,
}
impl EmailSearchArgs {
@@ -238,6 +240,7 @@ impl EmailSearchArgs {
.recipients(self.recipients)
.collapse(self.collapse)
.ids_only(self.ids_only)
+ .disable_recency(self.disable_recency)
.build_search_request()?
.to_json())
}
diff --git a/rust/cloud-storage/opensearch_client/src/search/projects.rs b/rust/cloud-storage/opensearch_client/src/search/projects.rs
index 2b7c92dca1..d56ee3837b 100644
--- a/rust/cloud-storage/opensearch_client/src/search/projects.rs
+++ b/rust/cloud-storage/opensearch_client/src/search/projects.rs
@@ -59,6 +59,7 @@ impl ProjectQueryBuilder {
fn collapse(collapse: bool) -> Self;
fn ids(ids: Vec<String>) -> Self;
fn ids_only(ids_only: bool) -> Self;
+ fn disable_recency(disable_recency: bool) -> Self;
}
fn build_search_request(self) -> Result<SearchRequest> {
@@ -95,11 +96,12 @@ pub struct ProjectSearchArgs {
pub search_on: SearchOn,
pub collapse: bool,
pub ids_only: bool,
+ pub disable_recency: bool,
}
impl ProjectSearchArgs {
pub fn build(self) -> Result<Value> {
- let builder = ProjectQueryBuilder::new(self.terms)
+ Ok(ProjectQueryBuilder::new(self.terms)
.match_type(&self.match_type)
.page_size(self.page_size)
.page(self.page)
@@ -107,9 +109,10 @@ impl ProjectSearchArgs {
.search_on(self.search_on)
.collapse(self.collapse)
.ids(self.project_ids)
- .ids_only(self.ids_only);
-
- Ok(builder.build_search_request()?.to_json())
+ .ids_only(self.ids_only)
+ .disable_recency(self.disable_recency)
+ .build_search_request()?
+ .to_json())
}
}
diff --git a/rust/cloud-storage/search_service/src/api/search/simple/simple_channel.rs b/rust/cloud-storage/search_service/src/api/search/simple/simple_channel.rs
index 273fb4a53b..2d4142e70f 100644
--- a/rust/cloud-storage/search_service/src/api/search/simple/simple_channel.rs
+++ b/rust/cloud-storage/search_service/src/api/search/simple/simple_channel.rs
@@ -143,6 +143,7 @@ pub(in crate::api::search) async fn search_channels(
search_on: req.search_on.into(),
collapse: req.collapse.unwrap_or(false),
ids_only: true, // For channel message search, we always want to search over the channel ids only
+ disable_recency: req.disable_recency,
})
.await
.map_err(SearchError::Search)?;
diff --git a/rust/cloud-storage/search_service/src/api/search/simple/simple_chat.rs b/rust/cloud-storage/search_service/src/api/search/simple/simple_chat.rs
index 3663c9c57c..5063cc515a 100644
--- a/rust/cloud-storage/search_service/src/api/search/simple/simple_chat.rs
+++ b/rust/cloud-storage/search_service/src/api/search/simple/simple_chat.rs
@@ -181,6 +181,7 @@ pub(in crate::api::search) async fn search_chats(
search_on: req.search_on.into(),
collapse: req.collapse.unwrap_or(false),
ids_only,
+ disable_recency: req.disable_recency,
})
.await
.map_err(SearchError::Search)?;
diff --git a/rust/cloud-storage/search_service/src/api/search/simple/simple_document.rs b/rust/cloud-storage/search_service/src/api/search/simple/simple_document.rs
index 822a2e1040..552b199ae6 100644
--- a/rust/cloud-storage/search_service/src/api/search/simple/simple_document.rs
+++ b/rust/cloud-storage/search_service/src/api/search/simple/simple_document.rs
@@ -202,6 +202,7 @@ pub(in crate::api::search) async fn search_documents(
search_on: req.search_on.into(),
collapse: req.collapse.unwrap_or(false),
ids_only,
+ disable_recency: req.disable_recency,
})
.await
.map_err(SearchError::Search)?;
diff --git a/rust/cloud-storage/search_service/src/api/search/simple/simple_email.rs b/rust/cloud-storage/search_service/src/api/search/simple/simple_email.rs
index 70d3f8bf64..2f5b461b57 100644
--- a/rust/cloud-storage/search_service/src/api/search/simple/simple_email.rs
+++ b/rust/cloud-storage/search_service/src/api/search/simple/simple_email.rs
@@ -104,6 +104,7 @@ pub(in crate::api::search) async fn search_emails(
search_on: req.search_on.into(),
collapse: req.collapse.unwrap_or(false),
ids_only: false, // TODO: implement
+ disable_recency: req.disable_recency,
})
.await
.map_err(SearchError::Search)?;
diff --git a/rust/cloud-storage/search_service/src/api/search/simple/simple_project.rs b/rust/cloud-storage/search_service/src/api/search/simple/simple_project.rs
index 5c034ebf63..6e51a57705 100644
--- a/rust/cloud-storage/search_service/src/api/search/simple/simple_project.rs
+++ b/rust/cloud-storage/search_service/src/api/search/simple/simple_project.rs
@@ -181,6 +181,7 @@ pub(in crate::api::search) async fn search_projects(
search_on: req.search_on.into(),
collapse: req.collapse.unwrap_or(false),
ids_only,
+ disable_recency: req.disable_recency,
})
.await
.map_err(SearchError::Search)?;
diff --git a/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rs b/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rs
index 25d3dbe673..889800e0ed 100644
--- a/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rs
+++ b/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rs
@@ -119,6 +119,7 @@ pub async fn handler(
// no filters means search all
let filters = req.filters.unwrap_or_default();
let match_type = req.match_type;
+ let disable_recency = req.disable_recency;
let include_all_items = req.include.is_empty();
@@ -137,6 +138,7 @@ pub async fn handler(
filters: filters.document,
search_on,
collapse: Some(collapse),
+ disable_recency,
};
let ctx = ctx.clone();
@@ -163,6 +165,7 @@ pub async fn handler(
filters: filters.chat,
search_on,
collapse: Some(collapse),
+ disable_recency,
};
let ctx = ctx.clone();
@@ -187,6 +190,7 @@ pub async fn handler(
filters: filters.email,
search_on,
collapse: Some(collapse),
+ disable_recency,
};
let ctx = ctx.clone();
@@ -215,6 +219,7 @@ pub async fn handler(
filters: filters.channel,
search_on,
collapse: Some(collapse),
+ disable_recency,
};
let ctx = ctx.clone();
@@ -248,6 +253,7 @@ pub async fn handler(
filters: filters.project,
search_on,
collapse: Some(collapse),
+ disable_recency,
};
let ctx = ctx.clone();
diff --git a/rust/cloud-storage/search_service/src/api/search/unified.rs b/rust/cloud-storage/search_service/src/api/search/unified.rs
index 3f5cd9c238..9ee74ac4fc 100644
--- a/rust/cloud-storage/search_service/src/api/search/unified.rs
+++ b/rust/cloud-storage/search_service/src/api/search/unified.rs
@@ -85,6 +85,7 @@ pub async fn handler(
// no filters means search all
let filters = req.filters.unwrap_or_default();
let match_type = req.match_type;
+ let disable_recency = req.disable_recency;
let mut tasks = FuturesUnordered::new();
@@ -103,6 +104,7 @@ pub async fn handler(
filters: filters.document,
search_on,
collapse: Some(collapse),
+ disable_recency,
};
let ctx = ctx.clone();
@@ -127,6 +129,7 @@ pub async fn handler(
filters: filters.chat,
search_on,
collapse: Some(collapse),
+ disable_recency,
};
let ctx = ctx.clone();
@@ -151,6 +154,7 @@ pub async fn handler(
filters: filters.email,
search_on,
collapse: Some(collapse),
+ disable_recency,
};
let ctx = ctx.clone();
@@ -175,6 +179,7 @@ pub async fn handler(
filters: filters.channel,
search_on,
collapse: Some(collapse),
+ disable_recency,
};
let ctx = ctx.clone();
@@ -208,6 +213,7 @@ pub async fn handler(
filters: filters.project,
search_on,
collapse: Some(collapse),
+ disable_recency,
};
let ctx = ctx.clone();