Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(search): remove dead code + add opensearch client example (#1942)
gbirmanf770e350e294
diff --git a/js/app/packages/service-clients/service-search/generated/models/channelSearchRequestAllOfTwo.ts b/js/app/packages/service-clients/service-search/generated/models/channelSearchRequestAllOfTwo.tsindex 0d7fcc173f..f96b292e2c 100644--- a/js/app/packages/service-clients/service-search/generated/models/channelSearchRequestAllOfTwo.ts+++ b/js/app/packages/service-clients/service-search/generated/models/channelSearchRequestAllOfTwo.ts@@ -13,9 +13,6 @@ import type { SearchOn } from './searchOn';export type ChannelSearchRequestAllOfTwo = {/** If true, returns only 1 result per entity. False by default. */collapse?: ChannelSearchRequestAllOfTwoCollapse;- /** If search_on is set to NameContent, you can disable the recency filter-by setting to true. */- disable_recency?: boolean;/** The match type to use when searching */match_type: MatchType;/** The query to search for */diff --git a/js/app/packages/service-clients/service-search/generated/models/chatSearchRequestAllOfTwo.ts b/js/app/packages/service-clients/service-search/generated/models/chatSearchRequestAllOfTwo.tsindex a780ccdadf..2194ec1f3f 100644--- a/js/app/packages/service-clients/service-search/generated/models/chatSearchRequestAllOfTwo.ts+++ b/js/app/packages/service-clients/service-search/generated/models/chatSearchRequestAllOfTwo.ts@@ -13,9 +13,6 @@ import type { SearchOn } from './searchOn';export type ChatSearchRequestAllOfTwo = {/** If true, returns only 1 result per entity. False by default. */collapse?: ChatSearchRequestAllOfTwoCollapse;- /** If search_on is set to NameContent, you can disable the recency filter-by setting to true. */- disable_recency?: boolean;/** The match type to use when searching */match_type: MatchType;/** The query to search for */diff --git a/js/app/packages/service-clients/service-search/generated/models/documentSearchRequestAllOfTwo.ts b/js/app/packages/service-clients/service-search/generated/models/documentSearchRequestAllOfTwo.tsindex 59b5758b6d..84bf13da64 100644--- a/js/app/packages/service-clients/service-search/generated/models/documentSearchRequestAllOfTwo.ts+++ b/js/app/packages/service-clients/service-search/generated/models/documentSearchRequestAllOfTwo.ts@@ -13,9 +13,6 @@ import type { SearchOn } from './searchOn';export type DocumentSearchRequestAllOfTwo = {/** If true, returns only 1 result per entity. False by default. */collapse?: DocumentSearchRequestAllOfTwoCollapse;- /** If search_on is set to NameContent, you can disable the recency filter-by setting to true. */- disable_recency?: boolean;/** The match type to use when searching */match_type: MatchType;/** The query to search for */diff --git a/js/app/packages/service-clients/service-search/generated/models/emailSearchRequestAllOfTwo.ts b/js/app/packages/service-clients/service-search/generated/models/emailSearchRequestAllOfTwo.tsindex bcd93eb0a2..ae738b3118 100644--- a/js/app/packages/service-clients/service-search/generated/models/emailSearchRequestAllOfTwo.ts+++ b/js/app/packages/service-clients/service-search/generated/models/emailSearchRequestAllOfTwo.ts@@ -13,9 +13,6 @@ import type { SearchOn } from './searchOn';export type EmailSearchRequestAllOfTwo = {/** If true, returns only 1 result per entity. False by default. */collapse?: EmailSearchRequestAllOfTwoCollapse;- /** If search_on is set to NameContent, you can disable the recency filter-by setting to true. */- disable_recency?: boolean;/** The match type to use when searching */match_type: MatchType;/** The query to search for */diff --git a/js/app/packages/service-clients/service-search/generated/models/projectSearchRequestAllOfTwo.ts b/js/app/packages/service-clients/service-search/generated/models/projectSearchRequestAllOfTwo.tsindex 25a8d5e7bd..ab6fb7d5a2 100644--- a/js/app/packages/service-clients/service-search/generated/models/projectSearchRequestAllOfTwo.ts+++ b/js/app/packages/service-clients/service-search/generated/models/projectSearchRequestAllOfTwo.ts@@ -14,9 +14,6 @@ import type { SearchOn } from './searchOn';export type ProjectSearchRequestAllOfTwo = {/** If true, returns only 1 result per entity. False by default. */collapse?: ProjectSearchRequestAllOfTwoCollapse;- /** If search_on is set to NameContent, you can disable the recency filter-by setting to true. */- disable_recency?: boolean;/** The match type to use when searching */match_type: MatchType;/** The query to search for */diff --git a/js/app/packages/service-clients/service-search/generated/models/unifiedSearchRequest.ts b/js/app/packages/service-clients/service-search/generated/models/unifiedSearchRequest.tsindex 4244381f22..d75b055cc8 100644--- a/js/app/packages/service-clients/service-search/generated/models/unifiedSearchRequest.ts+++ b/js/app/packages/service-clients/service-search/generated/models/unifiedSearchRequest.ts@@ -15,9 +15,6 @@ import type { UnifiedSearchRequestTerms } from './unifiedSearchRequestTerms';export interface UnifiedSearchRequest {collapse?: UnifiedSearchRequestCollapse;- /** If search_on is set to NameContent, you can disable the recency filter-by setting to true. */- disable_recency?: boolean;filters?: UnifiedSearchRequestFilters;/** 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?: UnifiedSearchIndex[];diff --git a/js/app/packages/service-clients/service-search/openapi.json b/js/app/packages/service-clients/service-search/openapi.jsonindex 118a4899f5..94dd69e4c4 100644--- a/js/app/packages/service-clients/service-search/openapi.json+++ b/js/app/packages/service-clients/service-search/openapi.json@@ -271,10 +271,6 @@"type": ["boolean", "null"],"description": "If true, returns only 1 result per entity. False by default."},- "disable_recency": {- "type": "boolean",- "description": "If search_on is set to NameContent, you can disable the recency filter\nby setting to true."- },"match_type": {"$ref": "#/components/schemas/MatchType","description": "The match type to use when searching"@@ -527,10 +523,6 @@"type": ["boolean", "null"],"description": "If true, returns only 1 result per entity. False by default."},- "disable_recency": {- "type": "boolean",- "description": "If search_on is set to NameContent, you can disable the recency filter\nby setting to true."- },"match_type": {"$ref": "#/components/schemas/MatchType","description": "The match type to use when searching"@@ -726,10 +718,6 @@"type": ["boolean", "null"],"description": "If true, returns only 1 result per entity. False by default."},- "disable_recency": {- "type": "boolean",- "description": "If search_on is set to NameContent, you can disable the recency filter\nby setting to true."- },"match_type": {"$ref": "#/components/schemas/MatchType","description": "The match type to use when searching"@@ -973,10 +961,6 @@"type": ["boolean", "null"],"description": "If true, returns only 1 result per entity. False by default."},- "disable_recency": {- "type": "boolean",- "description": "If search_on is set to NameContent, you can disable the recency filter\nby setting to true."- },"match_type": {"$ref": "#/components/schemas/MatchType","description": "The match type to use when searching"@@ -1752,10 +1736,6 @@"type": ["boolean", "null"],"description": "If true, returns only 1 result per entity. False by default."},- "disable_recency": {- "type": "boolean",- "description": "If search_on is set to NameContent, you can disable the recency filter\nby setting to true."- },"match_type": {"$ref": "#/components/schemas/MatchType","description": "The match type to use when searching"@@ -2888,10 +2868,6 @@"collapse": {"type": ["boolean", "null"]},- "disable_recency": {- "type": "boolean",- "description": "If search_on is set to NameContent, you can disable the recency filter\nby setting to true."- },"filters": {"oneOf": [{diff --git a/rust/cloud-storage/ai_tools/src/search/search_service/content.rs b/rust/cloud-storage/ai_tools/src/search/search_service/content.rsindex 69a5f849a5..74da65c6bf 100644--- a/rust/cloud-storage/ai_tools/src/search/search_service/content.rs+++ b/rust/cloud-storage/ai_tools/src/search/search_service/content.rs@@ -63,7 +63,6 @@ impl AsyncTool<Arc<SearchServiceClient>> for ContentSearch {search_on: models_search::SearchOn::Content,collapse: Some(true),include: self.entity_types.clone(),- disable_recency: false,};let response = search_clientdiff --git a/rust/cloud-storage/ai_tools/src/search/search_service/name.rs b/rust/cloud-storage/ai_tools/src/search/search_service/name.rsindex 0e61a5c90a..42829dff4d 100644--- a/rust/cloud-storage/ai_tools/src/search/search_service/name.rs+++ b/rust/cloud-storage/ai_tools/src/search/search_service/name.rs@@ -63,7 +63,6 @@ impl AsyncTool<Arc<SearchServiceClient>> for NameSearch {search_on: models_search::SearchOn::Name,collapse: Some(true),include: self.entity_types.clone(),- disable_recency: false,};let response = search_clientdiff --git a/rust/cloud-storage/models_search/src/channel.rs b/rust/cloud-storage/models_search/src/channel.rsindex 4bb88513de..a1dd2ab8da 100644--- a/rust/cloud-storage/models_search/src/channel.rs+++ b/rust/cloud-storage/models_search/src/channel.rs@@ -107,10 +107,6 @@ pub struct ChannelSearchRequest {pub terms: Option<Vec<String>>,/// The match type to use when searchingpub 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.rsindex 147eee8a6b..8ee94174ee 100644--- a/rust/cloud-storage/models_search/src/channel/test.rs+++ b/rust/cloud-storage/models_search/src/channel/test.rs@@ -15,11 +15,10 @@ 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","disable_recency":false,"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","thread_ids":["thread1","thread2"],"mentions":["@user1","@user2"],"org_id":12345,"search_on":"content"}"#;assert_eq!(json, expected);}@@ -93,7 +92,6 @@ 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.rsindex d0094ffaba..170bcb218d 100644--- a/rust/cloud-storage/models_search/src/chat.rs+++ b/rust/cloud-storage/models_search/src/chat.rs@@ -77,10 +77,6 @@ pub struct ChatSearchRequest {pub terms: Option<Vec<String>>,/// The match type to use when searchingpub 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.rsindex dfb3d03900..3ad19e2d5a 100644--- a/rust/cloud-storage/models_search/src/chat/test.rs+++ b/rust/cloud-storage/models_search/src/chat/test.rs@@ -17,11 +17,10 @@ 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","disable_recency":false,"role":["user","system"],"search_on":"content"}"#;+ let expected = r#"{"query":"test query","terms":["term1","term2"],"match_type":"exact","role":["user","system"],"search_on":"content"}"#;assert_eq!(json, expected);}@@ -92,7 +91,6 @@ 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.rsindex 437277dd04..9ab4565642 100644--- a/rust/cloud-storage/models_search/src/document.rs+++ b/rust/cloud-storage/models_search/src/document.rs@@ -127,10 +127,6 @@ pub struct DocumentSearchRequest {pub terms: Option<Vec<String>>,/// The match type to use when searchingpub 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.rsindex 50800ed0fd..7de08b6990 100644--- a/rust/cloud-storage/models_search/src/document/test.rs+++ b/rust/cloud-storage/models_search/src/document/test.rs@@ -17,11 +17,10 @@ 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","disable_recency":false,"file_types":["pdf","docx"],"search_on":"content"}"#;+ let expected = r#"{"query":"test query","terms":["term1","term2"],"match_type":"exact","file_types":["pdf","docx"],"search_on":"content"}"#;assert_eq!(json, expected);}@@ -92,7 +91,6 @@ 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.rsindex 78fefcea3e..56f83a1a56 100644--- a/rust/cloud-storage/models_search/src/email.rs+++ b/rust/cloud-storage/models_search/src/email.rs@@ -110,10 +110,6 @@ pub struct EmailSearchRequest {pub terms: Option<Vec<String>>,/// The match type to use when searchingpub 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.rsindex 324cca41c3..62edf70b96 100644--- a/rust/cloud-storage/models_search/src/email/test.rs+++ b/rust/cloud-storage/models_search/src/email/test.rs@@ -18,11 +18,10 @@ 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","disable_recency":false,"senders":["[email protected]"],"cc":["[email protected]"],"bcc":["[email protected]"],"search_on":"content"}"#;+ let expected = r#"{"query":"test query","terms":["term1","term2"],"match_type":"exact","senders":["[email protected]"],"cc":["[email protected]"],"bcc":["[email protected]"],"search_on":"content"}"#;assert_eq!(json, expected);}@@ -105,7 +104,6 @@ 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/lib.rs b/rust/cloud-storage/models_search/src/lib.rsindex c78ebfc2e1..260e48c859 100644--- a/rust/cloud-storage/models_search/src/lib.rs+++ b/rust/cloud-storage/models_search/src/lib.rs@@ -29,16 +29,6 @@ pub enum SearchOn {NameContent,}-impl From<SearchOn> for opensearch_client::SearchOn {- fn from(value: SearchOn) -> Self {- match value {- SearchOn::Name => opensearch_client::SearchOn::Name,- SearchOn::Content => opensearch_client::SearchOn::Content,- SearchOn::NameContent => opensearch_client::SearchOn::NameContent,- }- }-}-#[derive(Serialize, Deserialize, Debug, ToSchema, Copy, Clone, EnumString, Display, PartialEq, JsonSchema,)]diff --git a/rust/cloud-storage/models_search/src/project.rs b/rust/cloud-storage/models_search/src/project.rsindex 7dcaa65a18..f2e1b08b02 100644--- a/rust/cloud-storage/models_search/src/project.rs+++ b/rust/cloud-storage/models_search/src/project.rs@@ -85,10 +85,6 @@ pub struct ProjectSearchRequest {pub terms: Option<Vec<String>>,/// The match type to use when searchingpub 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.rsindex e8b7d364f9..50afeb8eee 100644--- a/rust/cloud-storage/models_search/src/unified.rs+++ b/rust/cloud-storage/models_search/src/unified.rs@@ -39,12 +39,6 @@ pub struct UnifiedSearchRequest {/// How to match the search terms. 'exact' for precise case-sensitive phrase matches, 'partial' for prefix/partial matches. REQUIRED field.pub match_type: MatchType,- /// 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>,diff --git a/rust/cloud-storage/opensearch_client/examples/unified_opensearch_query.rs b/rust/cloud-storage/opensearch_client/examples/unified_opensearch_query.rsnew file mode 100644index 0000000000..4e338e141c--- /dev/null+++ b/rust/cloud-storage/opensearch_client/examples/unified_opensearch_query.rs@@ -0,0 +1,23 @@+use std::collections::HashSet;++use models_opensearch::SearchEntityType;+use models_search_cursor::SearchCursorOption;+use opensearch_client::search::unified::{UnifiedEmailSearchArgs, UnifiedSearchArgs};++fn main() {+ let args = UnifiedSearchArgs {+ terms: vec!["hello re".to_string()],+ user_id: "macro|[email protected]".to_string(),+ page: 0,+ page_size: 10,+ match_type: "partial".to_string(),+ collapse: false,+ cursor: SearchCursorOption::NotDone(None),+ search_indices: HashSet::from([SearchEntityType::Emails]),+ email_search_args: UnifiedEmailSearchArgs::default(),+ ..Default::default()+ };++ let query_json = args.to_query_json().expect("failed to build query");+ println!("{}", serde_json::to_string_pretty(&query_json).unwrap());+}diff --git a/rust/cloud-storage/opensearch_client/src/channel_message.rs b/rust/cloud-storage/opensearch_client/src/channel_message.rsindex 01049dc8d3..f179b070b5 100644--- a/rust/cloud-storage/opensearch_client/src/channel_message.rs+++ b/rust/cloud-storage/opensearch_client/src/channel_message.rs@@ -1,6 +1,5 @@use crate::{OpensearchClient, Result, delete,- search::{self, channels::search_channel_messages, model::SearchHit},upsert::{self, channel_message::UpsertChannelMessageArgs},};@@ -33,13 +32,4 @@ impl OpensearchClient {delete::channel::delete_channel_message_by_id(&self.inner, channel_id, channel_message_id).await}-- /// Searches for channel messages in the opensearch index- #[tracing::instrument(skip(self))]- pub async fn search_channel_messages(- &self,- args: search::channels::ChannelMessageSearchArgs,- ) -> Result<Vec<SearchHit>> {- search_channel_messages(&self.inner, args).await- }}diff --git a/rust/cloud-storage/opensearch_client/src/chat.rs b/rust/cloud-storage/opensearch_client/src/chat.rsindex 0d83c80cb2..8719140098 100644--- a/rust/cloud-storage/opensearch_client/src/chat.rs+++ b/rust/cloud-storage/opensearch_client/src/chat.rs@@ -1,6 +1,5 @@use crate::{OpensearchClient, Result, delete,- search::{chats::search_chats, model::SearchHit},upsert::{self, chat_message::UpsertChatMessageArgs},};@@ -27,15 +26,6 @@ impl OpensearchClient {delete::chat::delete_chat_message_by_id(&self.inner, chat_id, chat_message_id).await}- /// Searches for chats in the opensearch index- #[tracing::instrument(skip(self))]- pub async fn search_chats(- &self,- args: crate::search::chats::ChatSearchArgs,- ) -> Result<Vec<SearchHit>> {- search_chats(&self.inner, args).await- }-pub async fn update_chat_metadata(&self, chat_id: &str, title: &str) -> Result<()> {upsert::chat_message::update_chat_metadata(&self.inner, chat_id, title).await}diff --git a/rust/cloud-storage/opensearch_client/src/document.rs b/rust/cloud-storage/opensearch_client/src/document.rsindex d1de8c9c59..da56713062 100644--- a/rust/cloud-storage/opensearch_client/src/document.rs+++ b/rust/cloud-storage/opensearch_client/src/document.rs@@ -1,6 +1,5 @@use crate::{OpensearchClient, Result, delete,- search::{self, documents::search_documents, model::SearchHit},upsert::{self, document::UpsertDocumentArgs},};@@ -20,15 +19,6 @@ impl OpensearchClient {upsert::document::bulk_upsert_documents(&self.inner, documents).await}- /// Searches for documents in the opensearch index- #[tracing::instrument(skip(self))]- pub async fn search_documents(- &self,- args: search::documents::DocumentSearchArgs,- ) -> Result<Vec<SearchHit>> {- search_documents(&self.inner, args).await- }-/// Deletes a document from the opensearch document index#[tracing::instrument(skip(self))]pub async fn delete_document(&self, document_id: &str) -> Result<()> {diff --git a/rust/cloud-storage/opensearch_client/src/email.rs b/rust/cloud-storage/opensearch_client/src/email.rsindex 5a65dce8b4..3520defa49 100644--- a/rust/cloud-storage/opensearch_client/src/email.rs+++ b/rust/cloud-storage/opensearch_client/src/email.rs@@ -1,9 +1,5 @@use crate::{OpensearchClient, Result, delete,- search::{- emails::{EmailSearchArgs, search_emails},- model::SearchHit,- },upsert::{self, BulkUpsertResult, email::UpsertEmailArgs},};@@ -23,10 +19,6 @@ impl OpensearchClient {upsert::email::bulk_upsert_email_messages(&self.inner, messages).await}- pub async fn search_emails(&self, args: EmailSearchArgs) -> Result<Vec<SearchHit>> {- search_emails(&self.inner, args).await- }-/// Deletes all email messages with the specified thread_idpub async fn delete_email_by_thread_id(&self, thread_id: &str) -> Result<()> {delete::email::delete_email_by_thread_id(&self.inner, thread_id).awaitdiff --git a/rust/cloud-storage/opensearch_client/src/error.rs b/rust/cloud-storage/opensearch_client/src/error.rsindex 4ecf6bb51c..4d13a342cc 100644--- a/rust/cloud-storage/opensearch_client/src/error.rs+++ b/rust/cloud-storage/opensearch_client/src/error.rs@@ -52,9 +52,6 @@ pub enum OpensearchClientError {#[error("empty ids with ids only for {0}")]EmptyIdsWithIdsOnly(SearchEntityType),- #[error("unsupported search_on")]- InvalidSearchOn,-#[error("searching with exhausted cursor")]SearchWithExhaustedCursor,}diff --git a/rust/cloud-storage/opensearch_client/src/lib.rs b/rust/cloud-storage/opensearch_client/src/lib.rsindex 3cefb9711e..b8485c9109 100644--- a/rust/cloud-storage/opensearch_client/src/lib.rs+++ b/rust/cloud-storage/opensearch_client/src/lib.rs@@ -3,12 +3,9 @@ pub mod delete;pub mod error;pub mod name;pub mod search;-pub mod search_on;pub mod unified;pub mod upsert;-pub use search_on::SearchOn;-pub mod channel_message;pub mod chat;pub mod document;diff --git a/rust/cloud-storage/opensearch_client/src/search/builder.rs b/rust/cloud-storage/opensearch_client/src/search/builder.rsindex 2021e52a6e..32d78c6865 100644--- a/rust/cloud-storage/opensearch_client/src/search/builder.rs+++ b/rust/cloud-storage/opensearch_client/src/search/builder.rs@@ -1,15 +1,14 @@use std::borrow::Cow;use crate::Result;-use crate::SearchOn;use crate::error::OpensearchClientError;-use crate::search::model::MacroEm;-use crate::search::query::Keys;use crate::search::query::QueryKey;use crate::search::query::generate_terms_must_query;use models_opensearch::SearchEntityType;use models_search_cursor::SearchMethodCursor;-use opensearch_query_builder::*;+use opensearch_query_builder::{+ BoolQueryBuilder, FieldSort, QueryType, Script, ScriptSort, ScriptSortType, SortOrder, SortType,+};/// A macro for generating delegation methods that forward calls to an inner field/// and return Self to maintain builder pattern chainability.@@ -46,28 +45,16 @@ macro_rules! delegate_methods {};}-/// Creates a highlight field-pub(crate) fn create_highlight_field<'a>(- highlight_type: &'a str,- number_of_fragments: u32,-) -> HighlightField<'a> {- HighlightField::new()- .highlight_type(highlight_type)- .pre_tags(vec![MacroEm::Open.to_string()])- .post_tags(vec![MacroEm::Close.to_string()])- .number_of_fragments(number_of_fragments)-}--/// Creates sort vec to sort by the updated_at with entity_id as a tiebreaker.-/// Items without a timestamp are pushed to the end by returning 0L (DESC order).+/// Creates sort vec to sort by sent_at_seconds (preferred) or updated_at_seconds (fallback)+/// with entity_id as a tiebreaker. Items without a timestamp are pushed to the end.pub(crate) fn updated_at_sort<'a>() -> Vec<SortType<'a>> {vec![SortType::ScriptSort(ScriptSort::new(Script::new(r#"if (doc.containsKey('sent_at_seconds') && doc['sent_at_seconds'].size() > 0) {- return doc['sent_at_seconds'].value.toInstant().toEpochMilli();+ return doc['sent_at_seconds'].value.millis;} else if (doc.containsKey('updated_at_seconds') && doc['updated_at_seconds'].size() > 0) {- return doc['updated_at_seconds'].value.toInstant().toEpochMilli();+ return doc['updated_at_seconds'].value.millis;} else {return 0L;}"#,@@ -97,31 +84,6 @@ pub trait SearchQueryConfig {const CONTENT_KEY: &'static str = "content";/// The entity index for the search queryconst ENTITY_INDEX: SearchEntityType;-- /// Returns the default sort types that are used on the search query.- /// Override this method if you need custom sort logic- fn default_sort_types<'a>() -> Vec<SortType<'a>> {- // Use the updated_at_sort by default- updated_at_sort()- }-- /// Override this method if you need custom highlight logic- fn default_highlight<'a>() -> Highlight<'a> {- Highlight::new().require_field_match(true).field(- "content",- HighlightField::new()- .highlight_type("plain")- .pre_tags(vec![MacroEm::Open.to_string()])- .post_tags(vec![MacroEm::Close.to_string()])- .number_of_fragments(500),- )- }-- /// Override this method if you want to add custom owner highlight fields- /// By default, this will add a user_id highlight field- fn append_owner_highlights<'a>(highlight: Highlight<'a>) -> Highlight<'a> {- highlight.field("user_id", create_highlight_field("plain", 1))- }}#[derive(Default)]@@ -139,8 +101,6 @@ pub struct SearchQueryBuilder<T: SearchQueryConfig> {pub page_size: u32,/// The user id to search forpub user_id: String,- /// Fields to search on (Name, Content, NameContent). Defaults to Content- pub search_on: SearchOn,/// Whether to collapse the results to be a single result per ID_KEY/// Defaults to false.pub collapse: bool,@@ -149,10 +109,6 @@ pub struct SearchQueryBuilder<T: SearchQueryConfig> {pub ids_only: bool,/// The ids to search for defaults to an empty vectorpub 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>,}@@ -164,11 +120,9 @@ impl<T: SearchQueryConfig> SearchQueryBuilder<T> {page: 0,page_size: 10,user_id: String::new(),- search_on: SearchOn::Content,collapse: false,ids_only: false,ids: Vec::new(),- disable_recency: false,_phantom: std::marker::PhantomData,}}@@ -193,11 +147,6 @@ impl<T: SearchQueryConfig> SearchQueryBuilder<T> {self}- pub fn search_on(mut self, search_on: SearchOn) -> Self {- self.search_on = search_on;- self- }-pub fn collapse(mut self, collapse: bool) -> Self {self.collapse = collapse;self@@ -213,11 +162,6 @@ impl<T: SearchQueryConfig> SearchQueryBuilder<T> {self}- pub fn disable_recency(mut self, disable_recency: bool) -> Self {- self.disable_recency = disable_recency;- self- }-/// Creates the filter query to filter results to only those a user has/// access to/has requested./// This could either be a single term/terms query for ids_only or just user_id@@ -259,21 +203,13 @@ impl<T: SearchQueryConfig> SearchQueryBuilder<T> {/// Builds a content bool querypub fn build_content_bool_query<'a>(&'a self) -> Result<BoolQueryBuilder<'a>> {- // We only support searching over content in opensearch now- if self.search_on == SearchOn::Name {- return Err(OpensearchClientError::InvalidSearchOn);- }- // FIXES: https://linear.app/macro-eng/issue/BAC-173/sending-invalid-queries-to-opensearch- // If we try and build queries with ids only = true and no ids provided we should- // error out as it creates an invalid query since we have minimum_should_match = 1.if self.ids_only && self.ids.is_empty() {return Err(OpensearchClientError::EmptyIdsWithIdsOnly(T::ENTITY_INDEX));}let mut access_bool_query = BoolQueryBuilder::new();- // For name OR content queries, we can build a much more simple bool query- let term_must_array: Vec<QueryType<'a>> = self.build_must_term_query(SearchOn::Content)?;+ let term_must_array: Vec<QueryType<'a>> = self.build_must_term_query()?;let mut inner_bool_query = BoolQueryBuilder::new();@@ -296,140 +232,17 @@ impl<T: SearchQueryConfig> SearchQueryBuilder<T> {Ok(access_bool_query)}- /// Builds the search request with the provided main bool query- /// This will automatically wrap the bool query in a function score if- /// SearchOn::NameContent is used- pub fn build_search_request<'a>(- &'a self,- query_object: BoolQuery<'a>,- ) -> Result<SearchRequest<'a>> {- let mut search_request: SearchRequestBuilder<'a> = SearchRequestBuilder::new();-- // Collapse on the ID_KEY if collapse is true- if self.collapse {- search_request.collapse(Collapse::new(T::ID_KEY));- }-- let mut highlight = match self.search_on {- SearchOn::Content => T::default_highlight(),- SearchOn::Name => Highlight::new().require_field_match(true).field(- T::TITLE_KEY,- HighlightField::new()- .highlight_type("plain")- .pre_tags(vec![MacroEm::Open.to_string()])- .post_tags(vec![MacroEm::Close.to_string()])- .number_of_fragments(1),- ),- SearchOn::NameContent => Highlight::new()- .require_field_match(false)- .field(- T::TITLE_KEY,- HighlightField::new()- .highlight_type("plain")- .pre_tags(vec![MacroEm::Open.to_string()])- .post_tags(vec![MacroEm::Close.to_string()])- .number_of_fragments(1),- )- .field(- T::CONTENT_KEY,- HighlightField::new()- .highlight_type("plain")- .pre_tags(vec![MacroEm::Open.to_string()])- .post_tags(vec![MacroEm::Close.to_string()])- .number_of_fragments(1),- ),- };-- highlight = T::append_owner_highlights(highlight);-- search_request.highlight(highlight);- search_request.set_sorts(T::default_sort_types().into());-- search_request.from(self.page * self.page_size);- search_request.size(self.page_size);-- let built_query: QueryType = match self.search_on {- SearchOn::Name | SearchOn::Content => query_object.into(),- SearchOn::NameContent => {- 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".into(),- origin: Some("now".into()),- scale: "21d".into(),- offset: Some("3d".into()),- 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 && !self.disable_recency {- search_request.track_total_hits(true);- search_request.add_agg(- "total_uniques".to_string(),- AggregationType::Cardinality(CardinalityAggregation::new(T::ID_KEY)),- );- }-- search_request.query(built_query);-- Ok(search_request.build())- }-- /// Generates a vec of term queries to be put inside of the bool must query- pub fn build_must_term_query<'a>(&'a self, search_on: SearchOn) -> Result<Vec<QueryType<'a>>> {- let keys = Keys {- title_key: T::TITLE_KEY,- content_key: T::CONTENT_KEY,- };-+ pub fn build_must_term_query<'a>(&'a self) -> Result<Vec<QueryType<'a>>> {if self.terms.is_empty() {return Err(OpensearchClientError::NoTermsProvided);}let query_key = QueryKey::from_match_type(&self.match_type)?;- let mut must_array = Vec::new();-let terms: Cow<'_, [&str]> =Cow::Owned(self.terms.iter().map(|t| t.as_str()).collect::<Vec<&str>>());- match search_on {- SearchOn::Name => {- must_array.push(generate_terms_must_query(- query_key,- keys.title_key,- terms,- None,- ));- }- SearchOn::Content => {- // map all terms over content key- must_array.push(generate_terms_must_query(- query_key,- keys.content_key,- terms,- None,- ));- }- SearchOn::NameContent => unreachable!(),- };+ let must_array = vec![generate_terms_must_query(query_key, T::CONTENT_KEY, terms)];Ok(must_array)}diff --git a/rust/cloud-storage/opensearch_client/src/search/builder/test.rs b/rust/cloud-storage/opensearch_client/src/search/builder/test.rsindex cae80e2714..71486590fb 100644--- a/rust/cloud-storage/opensearch_client/src/search/builder/test.rs+++ b/rust/cloud-storage/opensearch_client/src/search/builder/test.rs@@ -8,12 +8,6 @@ impl SearchQueryConfig for TestSearchConfig {const USER_ID_KEY: &'static str = "test_user_id";const TITLE_KEY: &'static str = "test_title";const ENTITY_INDEX: SearchEntityType = SearchEntityType::Documents;-- fn append_owner_highlights<'a>(- highlight: opensearch_query_builder::Highlight<'a>,- ) -> opensearch_query_builder::Highlight<'a> {- highlight.field("test_user_id", create_highlight_field("plain", 1))- }}#[test]@@ -82,164 +76,6 @@ fn test_build_filter_query() -> anyhow::Result<()> {Ok(())}-#[test]-fn test_build_search_request() -> anyhow::Result<()> {- let bool_query = QueryType::bool_query().build();-- let builder = SearchQueryBuilder::<TestSearchConfig>::new(vec!["test".to_string()])- .match_type("exact")- .page_size(20)- .page(1)- .user_id("user123")- .search_on(SearchOn::Content)- .collapse(true)- .ids(vec!["id1".to_string(), "id2".to_string()])- .ids_only(true);-- let result = builder.build_search_request(bool_query.clone())?;-- let expected = serde_json::json!({- "from": 20,- "size": 20,- "collapse": {- "field": "entity_id"- },- "sort": TestSearchConfig::default_sort_types().iter().map(|s| s.to_json()).collect::<Vec<_>>(),- "highlight": TestSearchConfig::append_owner_highlights(TestSearchConfig::default_highlight()).to_json(),- "query": {- "bool": {}- }- });-- 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)- .ids(vec!["id1".to_string(), "id2".to_string()]);-- let result = builder.build_search_request(bool_query.clone())?;-- let expected = serde_json::json!({- "track_total_hits": true,- "from": 20,- "size": 20,- "aggs": {- "total_uniques": {- "cardinality": {- "field": "entity_id"- }- }- },- "collapse": {- "field": "entity_id"- },- "sort": TestSearchConfig::default_sort_types().iter().map(|s| s.to_json()).collect::<Vec<_>>(),- "highlight": {- "require_field_match": false,- "fields": {- "content": {- "type": "plain",- "number_of_fragments": 1,- "pre_tags": ["<macro_em>"],- "post_tags": ["</macro_em>"],- },- "test_title": {- "type": "plain",- "number_of_fragments": 1,- "pre_tags": ["<macro_em>"],- "post_tags": ["</macro_em>"],- },- "test_user_id": {- "type": "plain",- "number_of_fragments": 1,- "pre_tags": ["<macro_em>"],- "post_tags": ["</macro_em>"],- }- }- },- "query": {- "function_score": {- "boost_mode": "multiply",- "functions": [- {- "gauss": {- "updated_at_seconds": {- "decay": 0.5,- "offset": "3d",- "origin": "now",- "scale": "21d"- }- },- "weight": 1.3- }- ],- "query": {- "bool": {}- },- "score_mode": "multiply"- }- }- });-- 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": "entity_id"- },- "sort": TestSearchConfig::default_sort_types().iter().map(|s| s.to_json()).collect::<Vec<_>>(),- "highlight": {- "require_field_match": false,- "fields": {- "content": {- "type": "plain",- "number_of_fragments": 1,- "pre_tags": ["<macro_em>"],- "post_tags": ["</macro_em>"],- },- "test_title": {- "type": "plain",- "number_of_fragments": 1,- "pre_tags": ["<macro_em>"],- "post_tags": ["</macro_em>"],- },- "test_user_id": {- "type": "plain",- "number_of_fragments": 1,- "pre_tags": ["<macro_em>"],- "post_tags": ["</macro_em>"],- }- }- },- "query": {- "bool": {}- }- });-- assert_eq!(result.to_json(), expected);-- Ok(())-}-#[test]fn test_build_contentquery_empty_ids() -> anyhow::Result<()> {// Empty ids ok with ids only false@@ -254,7 +90,6 @@ fn test_build_contentquery_empty_ids() -> anyhow::Result<()> {.page_size(page_size).page(page).user_id(user_id)- .search_on(SearchOn::Content).ids(ids.clone()).ids_only(false);@@ -268,7 +103,6 @@ fn test_build_contentquery_empty_ids() -> anyhow::Result<()> {.page_size(page_size).page(page).user_id(user_id)- .search_on(SearchOn::Content).ids(ids.clone()).ids_only(true);@@ -295,7 +129,6 @@ fn test_build_bool_query() -> anyhow::Result<()> {.page_size(page_size).page(page).user_id(user_id)- .search_on(SearchOn::Content).ids(ids.clone());let query = builder.build_content_bool_query()?;@@ -333,13 +166,12 @@ fn test_build_bool_query() -> anyhow::Result<()> {assert_eq!(query.build().to_json(), expected);- let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms.clone())+ let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms).match_type("partial").page_size(page_size).page(page).user_id(user_id).ids_only(true)- .search_on(SearchOn::Content).ids(ids.clone());let query = builder.build_content_bool_query()?;@@ -371,52 +203,6 @@ fn test_build_bool_query() -> anyhow::Result<()> {assert_eq!(query.build().to_json(), expected);- let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms)- .match_type("partial")- .page_size(page_size)- .page(page)- .user_id(user_id)- .ids_only(true)- .search_on(SearchOn::NameContent)- .ids(ids.clone());-- let query = builder.build_content_bool_query()?;-- let expected = serde_json::json!({- "bool": {- "must": [- {- "bool": {- "minimum_should_match": 1,- "should": [- {- "match_phrase_prefix": {- "content": {- "query": "test"- }- }- }- ]- }- },- ],- "filter": [- {- "terms": {- "entity_id": ["id1", "id2"]- }- },- {- "term": {- "_index": "documents",- }- }- ]- }- });-- assert_eq!(query.build().to_json(), expected);-Ok(())}@@ -424,11 +210,9 @@ fn test_build_bool_query() -> anyhow::Result<()> {fn test_build_must_term_query() -> anyhow::Result<()> {let terms = vec!["test".to_string()];- let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms.clone())- .match_type("exact")- .search_on(SearchOn::Content);+ let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms.clone()).match_type("exact");- let terms_must_vec = builder.build_must_term_query(SearchOn::Content)?;+ let terms_must_vec = builder.build_must_term_query()?;let expected = serde_json::json!({"match_phrase": {@@ -439,26 +223,9 @@ fn test_build_must_term_query() -> anyhow::Result<()> {assert_eq!(terms_must_vec.len(), 1);assert_eq!(terms_must_vec[0].to_json(), expected);- let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms.clone())- .match_type("exact")- .search_on(SearchOn::Name);-- let terms_must_vec = builder.build_must_term_query(SearchOn::Name)?;-- let expected = serde_json::json!({- "match_phrase": {- "test_title": "test"- }- });-- assert_eq!(terms_must_vec.len(), 1);- assert_eq!(terms_must_vec[0].to_json(), expected);-- let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms.clone())- .match_type("partial")- .search_on(SearchOn::Content);+ let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms.clone()).match_type("partial");- let terms_must_vec = builder.build_must_term_query(SearchOn::Content)?;+ let terms_must_vec = builder.build_must_term_query()?;let expected = serde_json::json!({"match_phrase_prefix": {@@ -478,11 +245,9 @@ fn test_build_must_term_query() -> anyhow::Result<()> {fn test_build_must_term_query_multiple_terms() -> anyhow::Result<()> {let terms = vec!["test1".to_string(), "test2".to_string()];- let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms.clone())- .match_type("exact")- .search_on(SearchOn::Content);+ let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms.clone()).match_type("exact");- let terms_must_vec = builder.build_must_term_query(SearchOn::Content)?;+ let terms_must_vec = builder.build_must_term_query()?;let expected = serde_json::json!({"bool": {@@ -511,11 +276,9 @@ fn test_build_must_term_query_multiple_terms() -> anyhow::Result<()> {#[test]fn test_build_must_term_query_term_with_short_last_word() -> anyhow::Result<()> {let terms = vec!["test Ab".to_string()];- let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms)- .match_type("partial")- .search_on(SearchOn::Content);+ let builder = SearchQueryBuilder::<TestSearchConfig>::new(terms).match_type("partial");- let terms_must_vec = builder.build_must_term_query(SearchOn::Content)?;+ let terms_must_vec = builder.build_must_term_query()?;let expected = serde_json::json!({"bool": {diff --git a/rust/cloud-storage/opensearch_client/src/search/channels.rs b/rust/cloud-storage/opensearch_client/src/search/channels.rsindex 08d12e3fdd..e225d79fd8 100644--- a/rust/cloud-storage/opensearch_client/src/search/channels.rs+++ b/rust/cloud-storage/opensearch_client/src/search/channels.rs@@ -1,20 +1,10 @@use crate::{Result, delegate_methods,- error::{OpensearchClientError, ResponseExt},- search::{- builder::{SearchQueryBuilder, SearchQueryConfig, create_highlight_field},- model::{- DefaultSearchResponse, NameIndex, SearchGotoChannel, SearchGotoContent, SearchHit,- exclude_source_content, inject_fragment_size, parse_highlight_hit,- },- query::Keys,- },+ search::builder::{SearchQueryBuilder, SearchQueryConfig},};-use crate::SearchOn;-use models_opensearch::{SearchEntityType, SearchIndex};-use opensearch_query_builder::{BoolQueryBuilder, QueryType, SearchRequest, ToOpenSearchJson};-use serde_json::Value;+use models_opensearch::SearchEntityType;+use opensearch_query_builder::{BoolQueryBuilder, QueryType};#[derive(Debug, serde::Serialize, serde::Deserialize)]pub(crate) struct ChannelMessageIndex {@@ -29,13 +19,6 @@ pub(crate) struct ChannelMessageIndex {pub updated_at_seconds: i64,}-#[derive(Debug, serde::Serialize, serde::Deserialize)]-#[serde(untagged)]-pub(crate) enum ChannelMessageNameIndex {- Name(NameIndex),- ChannelMessage(ChannelMessageIndex),-}-#[derive(Default)]pub(crate) struct ChannelMessageSearchConfig;@@ -43,12 +26,6 @@ impl SearchQueryConfig for ChannelMessageSearchConfig {const USER_ID_KEY: &'static str = "sender_id";const TITLE_KEY: &'static str = "name";const ENTITY_INDEX: SearchEntityType = SearchEntityType::Channels;-- fn append_owner_highlights<'a>(- highlight: opensearch_query_builder::Highlight<'a>,- ) -> opensearch_query_builder::Highlight<'a> {- highlight.field("sender_id", create_highlight_field("plain", 1))- }}#[derive(Default)]@@ -89,10 +66,8 @@ impl ChannelMessageQueryBuilder {fn page(page: u32) -> Self;fn page_size(page_size: u32) -> Self;fn user_id(user_id: &str) -> Self;- 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;}/// Builds the main bool query for the index@@ -118,17 +93,6 @@ impl ChannelMessageQueryBuilder {Ok(content_bool_query)}-- fn build_search_request<'a>(&'a self) -> Result<SearchRequest<'a>> {- let bool_query = self.build_bool_query()?;-- // Build the search request with the bool query- // This will automatically wrap the bool query in a function score if- // SearchOn::NameContent is used- let search_request = self.inner.build_search_request(bool_query.build())?;-- Ok(search_request)- }}#[derive(Debug, Default)]@@ -142,10 +106,8 @@ pub struct ChannelMessageSearchArgs {pub thread_ids: Vec<String>,pub mentions: Vec<String>,pub sender_ids: Vec<String>,- pub search_on: SearchOn,pub collapse: bool,pub ids_only: bool,- pub disable_recency: bool,}impl From<ChannelMessageSearchArgs> for ChannelMessageQueryBuilder {@@ -158,101 +120,11 @@ impl From<ChannelMessageSearchArgs> for ChannelMessageQueryBuilder {.thread_ids(args.thread_ids).mentions(args.mentions).ids(args.channel_ids)- .search_on(args.search_on).collapse(args.collapse).ids_only(args.ids_only).sender_ids(args.sender_ids)- .disable_recency(args.disable_recency)}}-impl ChannelMessageSearchArgs {- pub fn build(self) -> Result<Value> {- let builder: ChannelMessageQueryBuilder = self.into();- let mut json = builder.build_search_request()?.to_json();- inject_fragment_size(&mut json, 1000);- exclude_source_content(&mut json);- Ok(json)- }-}--#[tracing::instrument(skip(client, args), err)]-pub(crate) async fn search_channel_messages(- client: &opensearch::OpenSearch,- args: ChannelMessageSearchArgs,-) -> Result<Vec<SearchHit>> {- let query_body = args.build()?;-- let response = client- .search(opensearch::SearchParts::Index(&[- SearchIndex::Channels.as_ref()- ]))- .body(query_body)- .send()- .await- .map_client_error()- .await?;-- let bytes = response- .bytes()- .await- .map_err(|e| OpensearchClientError::HttpBytesError {- details: e.to_string(),- })?;-- let result: DefaultSearchResponse<ChannelMessageNameIndex> = serde_json::from_slice(&bytes)- .map_err(|e| OpensearchClientError::SearchDeserializationFailed {- details: e.to_string(),- raw_body: String::from_utf8_lossy(&bytes).to_string(),- })?;-- Ok(result- .hits- .hits- .into_iter()- .map(|hit| {- let highlight = hit- .highlight- .map(|h| {- parse_highlight_hit(- h,- Keys {- title_key: ChannelMessageSearchConfig::TITLE_KEY,- content_key: ChannelMessageSearchConfig::CONTENT_KEY,- },- )- })- .unwrap_or_default();-- match hit.source {- ChannelMessageNameIndex::Name(a) => SearchHit {- entity_id: a.entity_id,- entity_type: a.entity_type,- score: hit.score,- highlight,- goto: None,- updated_at: None,- },- ChannelMessageNameIndex::ChannelMessage(a) => SearchHit {- entity_id: a.entity_id,- entity_type: SearchEntityType::Channels,- score: hit.score,- highlight,- goto: Some(SearchGotoContent::Channels(SearchGotoChannel {- channel_message_id: a.message_id,- thread_id: a.thread_id,- sender_id: a.sender_id,- created_at: chrono::DateTime::from_timestamp(a.created_at_seconds, 0)- .unwrap_or_default(),- updated_at: chrono::DateTime::from_timestamp(a.updated_at_seconds, 0)- .unwrap_or_default(),- })),- updated_at: chrono::DateTime::from_timestamp(a.updated_at_seconds, 0),- },- }- })- .collect())-}-#[cfg(test)]mod test;diff --git a/rust/cloud-storage/opensearch_client/src/search/channels/test.rs b/rust/cloud-storage/opensearch_client/src/search/channels/test.rsindex 8749ef7829..ad7f3e8c64 100644--- a/rust/cloud-storage/opensearch_client/src/search/channels/test.rs+++ b/rust/cloud-storage/opensearch_client/src/search/channels/test.rs@@ -2,77 +2,51 @@ use super::*;use opensearch_query_builder::ToOpenSearchJson;#[test]-fn test_build_search_request() -> anyhow::Result<()> {+fn test_build_bool_query() -> anyhow::Result<()> {let builder = ChannelMessageQueryBuilder::new(vec!["test".to_string()]).match_type("exact").page_size(20).page(1).user_id("user123")- .search_on(SearchOn::Content).collapse(true).ids(vec!["id1".to_string(), "id2".to_string()]).thread_ids(vec!["thread1".to_string(), "thread2".to_string()]).mentions(vec!["mention1".to_string(), "mention2".to_string()]).sender_ids(vec!["sender1".to_string(), "sender2".to_string()]);- let result = builder.build_search_request()?;+ let result = builder.build_bool_query()?;let expected = serde_json::json!({- "collapse": {- "field": "entity_id"- },- "from": 20,- "highlight": ChannelMessageSearchConfig::append_owner_highlights(ChannelMessageSearchConfig::default_highlight()).to_json(),- "query": {- "bool": {- "must": [- {- "bool": {- "minimum_should_match": 1,- "should": [- {- "match_phrase": {- "content": "test"- }- }- ]- }- },- ],+ "bool": {+ "must": [+ {+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"match_phrase": {"content": "test"}}+ ]+ }+ }+ ],"filter": [- {- "bool": {- "minimum_should_match": 1,- "should": [- {"terms": {"entity_id": ["id1", "id2"]}},- {"term": {"sender_id": "user123"}}- ]- }- },- {"term": {"_index": "channels"}},- {- "terms": {- "thread_id": ["thread1", "thread2"]- }- },- {- "terms": {- "mentions": ["mention1", "mention2"]- }- },- {- "terms": {- "sender_id": ["sender1", "sender2"]- }- }- ]- }- },- "size": 20,- "sort": ChannelMessageSearchConfig::default_sort_types().iter().map(|s| s.to_json()).collect::<Vec<_>>(),+ {+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"terms": {"entity_id": ["id1", "id2"]}},+ {"term": {"sender_id": "user123"}}+ ]+ }+ },+ {"term": {"_index": "channels"}},+ {"terms": {"thread_id": ["thread1", "thread2"]}},+ {"terms": {"mentions": ["mention1", "mention2"]}},+ {"terms": {"sender_id": ["sender1", "sender2"]}}+ ]+ }});- assert_eq!(result.to_json(), expected);+ assert_eq!(result.build().to_json(), expected);Ok(())}diff --git a/rust/cloud-storage/opensearch_client/src/search/chats.rs b/rust/cloud-storage/opensearch_client/src/search/chats.rsindex dd03068c4a..67b9b327f8 100644--- a/rust/cloud-storage/opensearch_client/src/search/chats.rs+++ b/rust/cloud-storage/opensearch_client/src/search/chats.rs@@ -1,21 +1,13 @@use crate::{Result, delegate_methods,- error::{OpensearchClientError, ResponseExt},search::{builder::{SearchQueryBuilder, SearchQueryConfig},- model::{- DefaultSearchResponse, NameIndex, SearchGotoChat, SearchGotoContent, SearchHit,- exclude_source_content, inject_fragment_size, parse_highlight_hit,- },- query::Keys,utils::should_wildcard_field_query_builder,},};-use crate::SearchOn;-use models_opensearch::{SearchEntityType, SearchIndex};-use opensearch_query_builder::{BoolQueryBuilder, SearchRequest, ToOpenSearchJson};-use serde_json::Value;+use models_opensearch::SearchEntityType;+use opensearch_query_builder::BoolQueryBuilder;#[derive(Debug, serde::Serialize, serde::Deserialize)]pub(crate) struct ChatIndex {@@ -27,13 +19,6 @@ pub(crate) struct ChatIndex {pub updated_at_seconds: Option<i64>,}-#[derive(Debug, serde::Serialize, serde::Deserialize)]-#[serde(untagged)]-pub(crate) enum ChatNameIndex {- Name(NameIndex),- Chat(ChatIndex),-}-pub(crate) struct ChatSearchConfig;impl SearchQueryConfig for ChatSearchConfig {@@ -62,11 +47,9 @@ impl ChatQueryBuilder {fn page(page: u32) -> Self;fn page_size(page_size: u32) -> Self;fn user_id(user_id: &str) -> Self;- fn search_on(search_on: SearchOn) -> Self;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 {@@ -87,17 +70,6 @@ impl ChatQueryBuilder {Ok(content_bool_query)}-- fn build_search_request<'a>(&'a self) -> Result<SearchRequest<'a>> {- let bool_query = self.build_bool_query()?;-- // Build the search request with the bool query- // This will automatically wrap the bool query in a function score if- // SearchOn::NameContent is used- let search_request = self.inner.build_search_request(bool_query.build())?;-- Ok(search_request)- }}#[derive(Debug)]@@ -109,10 +81,8 @@ pub struct ChatSearchArgs {pub page_size: u32,pub match_type: String,pub role: Vec<String>,- pub search_on: SearchOn,pub collapse: bool,pub ids_only: bool,- pub disable_recency: bool,}impl From<ChatSearchArgs> for ChatQueryBuilder {@@ -124,97 +94,10 @@ impl From<ChatSearchArgs> for ChatQueryBuilder {.user_id(&args.user_id).ids(args.chat_ids).role(args.role)- .search_on(args.search_on).collapse(args.collapse).ids_only(args.ids_only)- .disable_recency(args.disable_recency)}}-impl ChatSearchArgs {- pub fn build(self) -> Result<Value> {- let builder: ChatQueryBuilder = self.into();- let mut json = builder.build_search_request()?.to_json();- inject_fragment_size(&mut json, 1000);- exclude_source_content(&mut json);- Ok(json)- }-}--#[tracing::instrument(skip(client, args), err)]-pub(crate) async fn search_chats(- client: &opensearch::OpenSearch,- args: ChatSearchArgs,-) -> Result<Vec<SearchHit>> {- let query_body = args.build()?;-- let response = client- .search(opensearch::SearchParts::Index(&[- SearchIndex::Chats.as_ref()- ]))- .body(query_body)- .send()- .await- .map_client_error()- .await?;-- let bytes = response- .bytes()- .await- .map_err(|e| OpensearchClientError::HttpBytesError {- details: e.to_string(),- })?;-- let result: DefaultSearchResponse<ChatNameIndex> =- serde_json::from_slice(&bytes).map_err(|e| {- OpensearchClientError::SearchDeserializationFailed {- details: e.to_string(),- raw_body: String::from_utf8_lossy(&bytes).to_string(),- }- })?;-- Ok(result- .hits- .hits- .into_iter()- .map(|hit| {- let highlight = hit- .highlight- .map(|h| {- parse_highlight_hit(- h,- Keys {- title_key: ChatSearchConfig::TITLE_KEY,- content_key: ChatSearchConfig::CONTENT_KEY,- },- )- })- .unwrap_or_default();-- match hit.source {- ChatNameIndex::Name(a) => SearchHit {- entity_id: a.entity_id,- entity_type: a.entity_type,- score: hit.score,- highlight,- goto: None,- updated_at: None,- },- ChatNameIndex::Chat(a) => SearchHit {- entity_id: a.entity_id,- entity_type: SearchEntityType::Chats,- score: hit.score,- highlight,- goto: Some(SearchGotoContent::Chats(SearchGotoChat {- chat_message_id: a.chat_message_id,- role: a.role,- })),- updated_at: None,- },- }- })- .collect())-}-#[cfg(test)]mod test;diff --git a/rust/cloud-storage/opensearch_client/src/search/chats/test.rs b/rust/cloud-storage/opensearch_client/src/search/chats/test.rsindex 8e407f17fe..7223fd8c16 100644--- a/rust/cloud-storage/opensearch_client/src/search/chats/test.rs+++ b/rust/cloud-storage/opensearch_client/src/search/chats/test.rs@@ -2,95 +2,55 @@ use super::*;use opensearch_query_builder::ToOpenSearchJson;#[test]-fn test_build_search_request() -> anyhow::Result<()> {+fn test_build_bool_query() -> anyhow::Result<()> {let builder = ChatQueryBuilder::new(vec!["test".to_string()]).match_type("exact").page_size(20).page(1).user_id("user123")- .search_on(SearchOn::Content).collapse(true).ids(vec!["chat1".to_string(), "chat2".to_string()]).role(vec!["user".to_string(), "assistant".to_string()]);- let result = builder.build_search_request()?;+ let result = builder.build_bool_query()?;let expected = serde_json::json!({- "from": 20,- "size": 20,- "collapse": {- "field": "entity_id"- },- "sort": ChatSearchConfig::default_sort_types().iter().map(|s| s.to_json()).collect::<Vec<_>>(),- "highlight": ChatSearchConfig::append_owner_highlights(ChatSearchConfig::default_highlight()).to_json(),- "query": {- "bool": {- "filter": [- {- "bool": {- "minimum_should_match": 1,- "should": [+ "bool": {+ "filter": [{- "terms": {- "entity_id": ["chat1", "chat2"]- }- },- {- "term": {- "user_id": "user123"- }- }- ]- }- },- {- "term": {- "_index": "chats"- }- },- {- "bool": {- "minimum_should_match": 1,- "should": [- {- "wildcard": {- "role": {- "case_insensitive": true,- "value": "*user*"+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"terms": {"entity_id": ["chat1", "chat2"]}},+ {"term": {"user_id": "user123"}}+ ]}- }},+ {"term": {"_index": "chats"}},{- "wildcard": {- "role": {- "case_insensitive": true,- "value": "*assistant*"+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"wildcard": {"role": {"case_insensitive": true, "value": "*user*"}}},+ {"wildcard": {"role": {"case_insensitive": true, "value": "*assistant*"}}}+ ]}- }}- ]- }- }- ],- "must": [- {- "bool": {- "minimum_should_match": 1,- "should": [+ ],+ "must": [{- "match_phrase": {- "content": "test"- }+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"match_phrase": {"content": "test"}}+ ]+ }}- ]- }- }- ]- }- },- });+ ]+ }+ });- assert_eq!(result.to_json(), expected);+ assert_eq!(result.build().to_json(), expected);Ok(())}diff --git a/rust/cloud-storage/opensearch_client/src/search/documents.rs b/rust/cloud-storage/opensearch_client/src/search/documents.rsindex 1e98ee5bad..c493c07687 100644--- a/rust/cloud-storage/opensearch_client/src/search/documents.rs+++ b/rust/cloud-storage/opensearch_client/src/search/documents.rs@@ -1,20 +1,10 @@use crate::{Result, delegate_methods,- error::{OpensearchClientError, ResponseExt},- search::{- builder::{SearchQueryBuilder, SearchQueryConfig, create_highlight_field},- model::{- DefaultSearchResponse, NameIndex, SearchGotoContent, SearchGotoDocument, SearchHit,- exclude_source_content, inject_fragment_size, parse_highlight_hit,- },- query::Keys,- },+ search::builder::{SearchQueryBuilder, SearchQueryConfig},};-use crate::SearchOn;-use models_opensearch::{SearchEntityType, SearchIndex};-use opensearch_query_builder::{BoolQueryBuilder, SearchRequest, ToOpenSearchJson};-use serde_json::Value;+use models_opensearch::SearchEntityType;+use opensearch_query_builder::BoolQueryBuilder;#[derive(Clone)]pub(crate) struct DocumentSearchConfig;@@ -23,12 +13,6 @@ impl SearchQueryConfig for DocumentSearchConfig {const USER_ID_KEY: &'static str = "owner_id";const TITLE_KEY: &'static str = "name";const ENTITY_INDEX: SearchEntityType = SearchEntityType::Documents;-- fn append_owner_highlights<'a>(- highlight: opensearch_query_builder::Highlight<'a>,- ) -> opensearch_query_builder::Highlight<'a> {- highlight.field("owner_id", create_highlight_field("plain", 1))- }}pub(crate) struct DocumentQueryBuilder {@@ -48,27 +32,14 @@ impl DocumentQueryBuilder {fn page(page: u32) -> Self;fn page_size(page_size: u32) -> Self;fn user_id(user_id: &str) -> Self;- fn search_on(search_on: SearchOn) -> Self;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 build_bool_query<'a>(&'a self) -> Result<BoolQueryBuilder<'a>> {self.inner.build_content_bool_query()}-- fn build_search_request<'a>(&'a self) -> Result<SearchRequest<'a>> {- // Build the search request with the bool query- // This will automatically wrap the bool query in a function score if- // SearchOn::NameContent is used- let search_request = self- .inner- .build_search_request(self.build_bool_query()?.build())?;-- Ok(search_request)- }}#[derive(Debug, serde::Serialize, serde::Deserialize)]@@ -82,13 +53,6 @@ pub(crate) struct DocumentIndex {pub updated_at_seconds: Option<i64>,}-#[derive(Debug, serde::Serialize, serde::Deserialize)]-#[serde(untagged)]-pub(crate) enum DocumentNameIndex {- Name(NameIndex),- Document(DocumentIndex),-}-#[derive(Debug)]pub struct DocumentSearchArgs {pub terms: Vec<String>,@@ -97,10 +61,8 @@ pub struct DocumentSearchArgs {pub page: u32,pub page_size: u32,pub match_type: String,- pub search_on: SearchOn,pub collapse: bool,pub ids_only: bool,- pub disable_recency: bool,}impl From<DocumentSearchArgs> for DocumentQueryBuilder {@@ -111,99 +73,10 @@ impl From<DocumentSearchArgs> for DocumentQueryBuilder {.page(args.page).user_id(&args.user_id).ids(args.document_ids)- .search_on(args.search_on).collapse(args.collapse).ids_only(args.ids_only)- .disable_recency(args.disable_recency)}}-impl DocumentSearchArgs {- pub fn build(self) -> Result<Value> {- let builder: DocumentQueryBuilder = self.into();- let mut json = builder.build_search_request()?.to_json();- inject_fragment_size(&mut json, 1000);- exclude_source_content(&mut json);- Ok(json)- }-}--#[tracing::instrument(skip(client, args), err)]-pub(crate) async fn search_documents(- client: &opensearch::OpenSearch,- args: DocumentSearchArgs,-) -> Result<Vec<SearchHit>> {- let query_body = args.build()?;-- tracing::trace!("query: {}", query_body);-- let response = client- .search(opensearch::SearchParts::Index(&[- SearchIndex::Documents.as_ref()- ]))- .body(query_body)- .send()- .await- .map_client_error()- .await?;-- let bytes = response- .bytes()- .await- .map_err(|e| OpensearchClientError::HttpBytesError {- details: e.to_string(),- })?;-- let result: DefaultSearchResponse<DocumentNameIndex> =- serde_json::from_slice(&bytes).map_err(|e| {- OpensearchClientError::SearchDeserializationFailed {- details: e.to_string(),- raw_body: String::from_utf8_lossy(&bytes).to_string(),- }- })?;-- Ok(result- .hits- .hits- .into_iter()- .map(|hit| {- let highlight = hit- .highlight- .map(|h| {- parse_highlight_hit(- h,- Keys {- title_key: DocumentSearchConfig::TITLE_KEY,- content_key: DocumentSearchConfig::CONTENT_KEY,- },- )- })- .unwrap_or_default();-- match hit.source {- DocumentNameIndex::Name(a) => SearchHit {- entity_id: a.entity_id,- entity_type: a.entity_type,- score: hit.score,- highlight,- goto: None,- updated_at: None,- },- DocumentNameIndex::Document(a) => SearchHit {- entity_id: a.entity_id,- entity_type: SearchEntityType::Documents,- score: hit.score,- highlight,- goto: Some(SearchGotoContent::Documents(SearchGotoDocument {- node_id: a.node_id,- raw_content: a.raw_content,- })),- updated_at: None,- },- }- })- .collect())-}-#[cfg(test)]mod test;diff --git a/rust/cloud-storage/opensearch_client/src/search/documents/test.rs b/rust/cloud-storage/opensearch_client/src/search/documents/test.rsindex e89feb3708..3d41565a89 100644--- a/rust/cloud-storage/opensearch_client/src/search/documents/test.rs+++ b/rust/cloud-storage/opensearch_client/src/search/documents/test.rs@@ -2,71 +2,45 @@ use super::*;use opensearch_query_builder::ToOpenSearchJson;#[test]-fn test_build_search_request() -> anyhow::Result<()> {+fn test_build_bool_query() -> anyhow::Result<()> {let builder = DocumentQueryBuilder::new(vec!["test".to_string()]).match_type("exact").page_size(20).page(1).user_id("user123")- .search_on(SearchOn::Content).collapse(true).ids(vec!["doc1".to_string(), "doc2".to_string()]);- let result = builder.build_search_request()?;+ let result = builder.build_bool_query()?;let expected = serde_json::json!({- "from": 20,- "size": 20,- "collapse": {- "field": "entity_id"- },- "sort": DocumentSearchConfig::default_sort_types().iter().map(|s| s.to_json()).collect::<Vec<_>>(),- "highlight": DocumentSearchConfig::append_owner_highlights(DocumentSearchConfig::default_highlight()).to_json(),- "query": {- "bool": {- "filter": [- {- "bool": {- "minimum_should_match": 1,- "should": [- {- "terms": {- "entity_id": ["doc1", "doc2"]- }- },- {- "term": {- "owner_id": "user123"- }- }- ]- }- },- {- "term": {- "_index": "documents"- }- }- ],- "must": [- {- "bool": {- "minimum_should_match": 1,- "should": [- {- "match_phrase": {- "content": "test"- }- }- ]- }- }- ]- }- },+ "bool": {+ "filter": [+ {+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"terms": {"entity_id": ["doc1", "doc2"]}},+ {"term": {"owner_id": "user123"}}+ ]+ }+ },+ {"term": {"_index": "documents"}}+ ],+ "must": [+ {+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"match_phrase": {"content": "test"}}+ ]+ }+ }+ ]+ }});- assert_eq!(result.to_json(), expected);+ assert_eq!(result.build().to_json(), expected);Ok(())}diff --git a/rust/cloud-storage/opensearch_client/src/search/emails.rs b/rust/cloud-storage/opensearch_client/src/search/emails.rsindex 39f946e8dd..e146d7791c 100644--- a/rust/cloud-storage/opensearch_client/src/search/emails.rs+++ b/rust/cloud-storage/opensearch_client/src/search/emails.rs@@ -1,25 +1,13 @@use crate::{Result, delegate_methods,- error::{OpensearchClientError, ResponseExt},search::{builder::{SearchQueryBuilder, SearchQueryConfig},- model::{- NameIndex, SearchGotoContent, SearchGotoEmail, SearchHit, exclude_source_content,- inject_fragment_size, parse_highlight_hit,- },- query::Keys,utils::should_wildcard_field_query_builder,},};-use crate::SearchOn;-use models_opensearch::{SearchEntityType, SearchIndex};-use opensearch_query_builder::{- BoolQuery, BoolQueryBuilder, QueryType, SearchRequest, ToOpenSearchJson,-};--use crate::search::model::DefaultSearchResponse;-use serde_json::Value;+use models_opensearch::SearchEntityType;+use opensearch_query_builder::{BoolQuery, BoolQueryBuilder, QueryType};pub(crate) struct EmailSearchConfig;@@ -72,11 +60,9 @@ impl EmailQueryBuilder {fn page(page: u32) -> Self;fn page_size(page_size: u32) -> Self;fn user_id(user_id: &str) -> Self;- fn search_on(search_on: SearchOn) -> Self;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 link_ids(mut self, link_ids: Vec<String>) -> Self {@@ -205,17 +191,6 @@ impl EmailQueryBuilder {Ok(content_bool_query)}-- fn build_search_request<'a>(&'a self) -> Result<SearchRequest<'a>> {- // Build the search request with the bool query- // This will automatically wrap the bool query in a function score if- // SearchOn::NameContent is used- let search_request = self- .inner- .build_search_request(self.build_bool_query()?.build())?;-- Ok(search_request)- }}#[derive(Debug, serde::Serialize, serde::Deserialize)]@@ -259,13 +234,6 @@ pub(crate) struct EmailIndex {pub sent_at_seconds: Option<i64>,}-#[derive(Debug, serde::Serialize, serde::Deserialize)]-#[serde(untagged)]-pub(crate) enum EmailNameIndex {- Email(Box<EmailIndex>),- Name(NameIndex),-}-pub struct EmailSearchArgs {pub terms: Vec<String>,pub user_id: String,@@ -281,10 +249,8 @@ pub struct EmailSearchArgs {pub page: u32,pub page_size: u32,pub match_type: String,- pub search_on: SearchOn,pub collapse: bool,pub ids_only: bool,- pub disable_recency: bool,}impl From<EmailSearchArgs> for EmailQueryBuilder {@@ -299,112 +265,14 @@ impl From<EmailSearchArgs> for EmailQueryBuilder {.sender(args.sender).cc(args.cc).bcc(args.bcc)- .search_on(args.search_on).recipients(args.recipients).include_labels(args.include_labels).exclude_labels(args.exclude_labels).importance(args.importance).collapse(args.collapse).ids_only(args.ids_only)- .disable_recency(args.disable_recency)- }-}--impl EmailSearchArgs {- pub fn build(self) -> Result<Value> {- let builder: EmailQueryBuilder = self.into();- let mut json = builder.build_search_request()?.to_json();- inject_fragment_size(&mut json, 1000);- exclude_source_content(&mut json);- Ok(json)}}-#[tracing::instrument(skip(client, args), err)]-pub(crate) async fn search_emails(- client: &opensearch::OpenSearch,- args: EmailSearchArgs,-) -> Result<Vec<SearchHit>> {- let query_body = args.build()?;-- tracing::trace!("query: {}", query_body);-- let response = client- .search(opensearch::SearchParts::Index(&[- SearchIndex::Emails.as_ref()- ]))- .body(query_body)- .send()- .await- .map_client_error()- .await?;-- let bytes = response- .bytes()- .await- .map_err(|e| OpensearchClientError::HttpBytesError {- details: e.to_string(),- })?;-- let result: DefaultSearchResponse<EmailNameIndex> =- serde_json::from_slice(&bytes).map_err(|e| {- OpensearchClientError::SearchDeserializationFailed {- details: e.to_string(),- raw_body: String::from_utf8_lossy(&bytes).to_string(),- }- })?;-- Ok(result- .hits- .hits- .into_iter()- .map(|hit| {- let highlight = hit- .highlight- .map(|h| {- parse_highlight_hit(- h,- Keys {- title_key: EmailSearchConfig::TITLE_KEY,- content_key: EmailSearchConfig::CONTENT_KEY,- },- )- })- .unwrap_or_default();-- match hit.source {- EmailNameIndex::Name(a) => SearchHit {- entity_id: a.entity_id,- entity_type: a.entity_type,- goto: None,- score: hit.score,- highlight,- updated_at: None,- },- EmailNameIndex::Email(a) => SearchHit {- entity_id: a.entity_id,- entity_type: SearchEntityType::Emails,- score: hit.score,- highlight,- goto: Some(SearchGotoContent::Emails(SearchGotoEmail {- email_message_id: a.message_id,- bcc: a.bcc,- cc: a.cc,- labels: a.labels,- sent_at: a- .sent_at_seconds- .and_then(|ts| chrono::DateTime::from_timestamp(ts, 0)),- sender: a.sender,- recipients: a.recipients,- })),- updated_at: a- .sent_at_seconds- .and_then(|s| chrono::DateTime::from_timestamp(s, 0)),- },- }- })- .collect())-}-#[cfg(test)]mod test;diff --git a/rust/cloud-storage/opensearch_client/src/search/emails/test.rs b/rust/cloud-storage/opensearch_client/src/search/emails/test.rsindex 0504255aed..5b1631b7fd 100644--- a/rust/cloud-storage/opensearch_client/src/search/emails/test.rs+++ b/rust/cloud-storage/opensearch_client/src/search/emails/test.rs@@ -2,13 +2,12 @@ use super::*;use opensearch_query_builder::ToOpenSearchJson;#[test]-fn test_build_search_request() -> anyhow::Result<()> {+fn test_build_bool_query() -> anyhow::Result<()> {let builder = EmailQueryBuilder::new(vec!["test".to_string()]).match_type("exact").page_size(20).page(1).user_id("user123")- .search_on(SearchOn::Content).collapse(true).ids(vec!["thread1".to_string(), "thread2".to_string()]).link_ids(vec!["link1".to_string(), "link2".to_string()])@@ -17,126 +16,69 @@ fn test_build_search_request() -> anyhow::Result<()> {.bcc(vec!["[email protected]".to_string()]).recipients(vec!["[email protected]".to_string()]);- let result = builder.build_search_request()?;+ let result = builder.build_bool_query()?;let expected = serde_json::json!({- "from": 20,- "size": 20,- "collapse": {- "field": "entity_id"- },- "sort": EmailSearchConfig::default_sort_types().iter().map(|s| s.to_json()).collect::<Vec<_>>(),- "highlight": EmailSearchConfig::append_owner_highlights(EmailSearchConfig::default_highlight()).to_json(),- "query": {- "bool": {- "filter": [- {- "bool": {- "minimum_should_match": 1,- "should": [+ "bool": {+ "filter": [{- "terms": {- "entity_id": ["thread1", "thread2"]- }+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"terms": {"entity_id": ["thread1", "thread2"]}},+ {"term": {"user_id": "user123"}}+ ]+ }},+ {"term": {"_index": "emails_alias"}},+ {"terms": {"link_id": ["link1", "link2"]}},{- "term": {- "user_id": "user123"- }- }- ]- }- },- {- "term": {- "_index": "emails_alias"- }- },- {- "terms": {- "link_id": ["link1", "link2"]- }- },- {- "bool": {- "minimum_should_match": 1,- "should": [- {- "wildcard": {- "sender": {- "case_insensitive": true,- "value": "*[email protected]*"+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"wildcard": {"sender": {"case_insensitive": true, "value": "*[email protected]*"}}}+ ]}- }- }- ]- }- },- {- "bool": {- "minimum_should_match": 1,- "should": [+ },{- "wildcard": {- "cc": {- "case_insensitive": true,- "value": "*[email protected]*"+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"wildcard": {"cc": {"case_insensitive": true, "value": "*[email protected]*"}}}+ ]}- }- }- ]- }- },- {- "bool": {- "minimum_should_match": 1,- "should": [+ },{- "wildcard": {- "bcc": {- "case_insensitive": true,- "value": "*[email protected]*"+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"wildcard": {"bcc": {"case_insensitive": true, "value": "*[email protected]*"}}}+ ]}- }- }- ]- }- },- {- "bool": {- "minimum_should_match": 1,- "should": [+ },{- "wildcard": {- "recipients": {- "case_insensitive": true,- "value": "*[email protected]*"+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"wildcard": {"recipients": {"case_insensitive": true, "value": "*[email protected]*"}}}+ ]}- }}- ]- }- }- ],- "must": [- {- "bool": {- "minimum_should_match": 1,- "should": [+ ],+ "must": [{- "match_phrase": {- "content": "test"- }+ "bool": {+ "minimum_should_match": 1,+ "should": [+ {"match_phrase": {"content": "test"}}+ ]+ }}- ]- }- }- ],- }- },- });+ ]+ }+ });- assert_eq!(result.to_json(), expected);+ assert_eq!(result.build().to_json(), expected);Ok(())}@@ -148,7 +90,6 @@ fn test_importance_true_excludes_depriority_unless_priority() -> anyhow::Result<.page_size(10).page(0).user_id("user123")- .search_on(SearchOn::Content).collapse(false).importance(Some(true));@@ -179,7 +120,6 @@ fn test_importance_false_filters_to_depriority_only() -> anyhow::Result<()> {.page_size(10).page(0).user_id("user123")- .search_on(SearchOn::Content).collapse(false).importance(Some(false));@@ -212,7 +152,6 @@ fn test_importance_none_no_importance_filter() -> anyhow::Result<()> {.page_size(10).page(0).user_id("user123")- .search_on(SearchOn::Content).collapse(false).importance(None);@@ -231,7 +170,6 @@ fn test_importance_true_with_exclude_labels_both_apply() -> anyhow::Result<()> {.page_size(10).page(0).user_id("user123")- .search_on(SearchOn::Content).collapse(false).importance(Some(true)).exclude_labels(vec!["INBOX".to_string()]);@@ -261,7 +199,6 @@ fn test_importance_false_with_exclude_labels_both_apply() -> anyhow::Result<()>.page_size(10).page(0).user_id("user123")- .search_on(SearchOn::Content).collapse(false).importance(Some(false)).exclude_labels(vec!["CATEGORY_SOCIAL".to_string()]);diff --git a/rust/cloud-storage/opensearch_client/src/search/model.rs b/rust/cloud-storage/opensearch_client/src/search/model.rsindex 590c426a30..bb3ed36c0a 100644--- a/rust/cloud-storage/opensearch_client/src/search/model.rs+++ b/rust/cloud-storage/opensearch_client/src/search/model.rs@@ -250,18 +250,6 @@ pub(crate) struct SearchResponse<T> {pub _shards: Shards,}-#[derive(Debug, serde::Serialize, serde::Deserialize)]-pub struct NameIndex {- /// The entity id- pub entity_id: uuid::Uuid,- /// The entity type- pub entity_type: SearchEntityType,- /// The name of the entity- pub name: String,- /// The creator of the entity- pub user_id: String,-}-#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)]pub struct SearchGotoDocument {/// The node id of the document.diff --git a/rust/cloud-storage/opensearch_client/src/search/query.rs b/rust/cloud-storage/opensearch_client/src/search/query.rsindex 53ab391f7b..f4d8d20aae 100644--- a/rust/cloud-storage/opensearch_client/src/search/query.rs+++ b/rust/cloud-storage/opensearch_client/src/search/query.rs@@ -2,7 +2,7 @@use std::borrow::Cow;-use crate::{Result, error::OpensearchClientError, search_on::NameOrContent};+use crate::{Result, error::OpensearchClientError};use opensearch_query_builder::*;use unicode_segmentation::UnicodeSegmentation;@@ -33,111 +33,71 @@ fn validate_last_term_length(term: &str) -> bool {pub(crate) struct CreateQueryParams<'a> {/// The query key to use- /// This is only used if unified params are not providedpub query_key: QueryKey,/// The field to search onpub field: &'a str,/// The term to search forpub term: &'a str,- /// Optional unified search params- /// If present, the unified search field is used- pub unified_params: Option<&'a CreateQueryUnifiedParams>,-}--pub(crate) struct CreateQueryUnifiedParams {- /// Specifies whether the unified search field is a name or content field- /// This is used to determine the boosting of the match queries- pub name_or_content: NameOrContent,}/// Creates a query for a given term+/// Fixes https://linear.app/macro-eng/issue/M-5094/unified-search-match-prefix-on-phrase-should-not-constrain-termspub(crate) fn create_query<'a>(params: CreateQueryParams<'a>) -> QueryType<'a> {let CreateQueryParams {query_key,field,term,- unified_params,} = params;- if let Some(unified_params) = unified_params {- let name_or_content = unified_params.name_or_content;- // base bool query- let mut bool_query = BoolQueryBuilder::new();- bool_query.minimum_should_match(1);+ // We need to create a more complex combo query if the last word in a term is less than 3 characters.+ let mut terms = term.split(' ').collect::<Vec<_>>();+ let last_term = terms.last().unwrap_or(&"");+ let is_last_term_long_enough = validate_last_term_length(last_term);- let mut match_phrase_prefix_query = MatchPhrasePrefixQuery::new(field.to_string(), term);- let mut match_query = MatchQuery::new(field.to_string(), term);+ if !last_term.is_empty() && !is_last_term_long_enough && terms.len() > 1 {+ tracing::trace!("last value in term has length less than 3, building combo query");- match name_or_content {- NameOrContent::Name => {- match_phrase_prefix_query = match_phrase_prefix_query.boost(1000.0);- match_query = match_query.boost(0.1).minimum_should_match("80%");- }- NameOrContent::Content => {- match_phrase_prefix_query = match_phrase_prefix_query.boost(900.0);- match_query = match_query- .boost(0.09)- .minimum_should_match(term.split(' ').count().to_string());- }- }-- bool_query.should(match_phrase_prefix_query.into());- bool_query.should(match_query.into());-- bool_query.build().into()- } else {- // Fixes https://linear.app/macro-eng/issue/M-5094/unified-search-match-prefix-on-phrase-should-not-constrain-terms- // We need to create a more complex combo query if the last word in a term is less than 3 characters.- let mut terms = term.split(' ').collect::<Vec<_>>();- let last_term = terms.last().unwrap_or(&"");- let is_last_term_long_enough = validate_last_term_length(last_term);-- if !last_term.is_empty() && !is_last_term_long_enough && terms.len() > 1 {- tracing::trace!("last value in term has length less than 3, building combo query");-- let last_part_of_term = terms.pop().unwrap();- let first_part_of_term = terms.join(" ");- let wildcard_pattern = format!("*{}*", last_part_of_term.to_lowercase());-- // build the first term query- let first_term_query = match query_key {- QueryKey::MatchPhrase => QueryType::MatchPhrase(MatchPhraseQuery::new(- field.to_string(),- first_part_of_term,- )),- QueryKey::MatchPhrasePrefix => QueryType::MatchPhrasePrefix(- MatchPhrasePrefixQuery::new(field.to_string(), first_part_of_term),- ),- QueryKey::Regexp => {- QueryType::Regexp(RegexpQuery::new(field.to_string(), first_part_of_term))- }- };-- let second_term_query = QueryType::WildCard(WildcardQuery::new(- field.to_string(),- wildcard_pattern,- true,- None,- ));-- let mut bool_query = QueryType::bool_query();-- bool_query.must(first_term_query);- bool_query.must(second_term_query);-- return bool_query.build().into();- }+ let last_part_of_term = terms.pop().unwrap();+ let first_part_of_term = terms.join(" ");+ let wildcard_pattern = format!("*{}*", last_part_of_term.to_lowercase());- match query_key {+ let first_term_query = match query_key {QueryKey::MatchPhrase => {- QueryType::MatchPhrase(MatchPhraseQuery::new(field.to_string(), term.to_string()))+ QueryType::MatchPhrase(MatchPhraseQuery::new(field.to_string(), first_part_of_term))}QueryKey::MatchPhrasePrefix => QueryType::MatchPhrasePrefix(- MatchPhrasePrefixQuery::new(field.to_string(), term.to_string()),+ MatchPhrasePrefixQuery::new(field.to_string(), first_part_of_term),),QueryKey::Regexp => {- QueryType::Regexp(RegexpQuery::new(field.to_string(), term.to_string()))+ QueryType::Regexp(RegexpQuery::new(field.to_string(), first_part_of_term))}+ };++ let second_term_query = QueryType::WildCard(WildcardQuery::new(+ field.to_string(),+ wildcard_pattern,+ true,+ None,+ ));++ let mut bool_query = QueryType::bool_query();++ bool_query.must(first_term_query);+ bool_query.must(second_term_query);++ return bool_query.build().into();+ }++ match query_key {+ QueryKey::MatchPhrase => {+ QueryType::MatchPhrase(MatchPhraseQuery::new(field.to_string(), term.to_string()))+ }+ QueryKey::MatchPhrasePrefix => QueryType::MatchPhrasePrefix(MatchPhrasePrefixQuery::new(+ field.to_string(),+ term.to_string(),+ )),+ QueryKey::Regexp => {+ QueryType::Regexp(RegexpQuery::new(field.to_string(), term.to_string()))}}}@@ -161,7 +121,6 @@ pub(crate) fn generate_terms_must_query<'a>(query_key: QueryKey,field: &'a str,terms: impl Into<Cow<'a, [&'a str]>>,- unified_params: Option<&'a CreateQueryUnifiedParams>,) -> QueryType<'a> {let mut terms_must_query = BoolQueryBuilder::new();@@ -177,7 +136,6 @@ pub(crate) fn generate_terms_must_query<'a>(query_key,field,term,- unified_params,})}).collect();diff --git a/rust/cloud-storage/opensearch_client/src/search/query/test.rs b/rust/cloud-storage/opensearch_client/src/search/query/test.rsindex 1a8fe4b3d8..3c58daace9 100644--- a/rust/cloud-storage/opensearch_client/src/search/query/test.rs+++ b/rust/cloud-storage/opensearch_client/src/search/query/test.rs@@ -39,7 +39,6 @@ fn test_query_key_create_query() -> anyhow::Result<()> {query_key,field,term,- unified_params: None,}).to_json();@@ -79,7 +78,6 @@ fn test_query_key_short_last_word() -> anyhow::Result<()> {query_key: QueryKey::MatchPhrasePrefix,field,term,- unified_params: None,}).to_json();@@ -92,7 +90,7 @@ fn test_query_key_short_last_word() -> anyhow::Result<()> {fn test_generate_terms_must_query() -> anyhow::Result<()> {let terms: Cow<'_, [&str]> = Cow::Borrowed(&["test"]);- let result = generate_terms_must_query(QueryKey::MatchPhrase, "test", terms, None);+ let result = generate_terms_must_query(QueryKey::MatchPhrase, "test", terms);let expected = serde_json::json!({"match_phrase": {@@ -103,7 +101,7 @@ fn test_generate_terms_must_query() -> anyhow::Result<()> {assert_eq!(result.to_json(), expected);let terms: Cow<'_, [&str]> = Cow::Borrowed(&["test", "test2"]);- let result = generate_terms_must_query(QueryKey::MatchPhrasePrefix, "test", terms, None);+ let result = generate_terms_must_query(QueryKey::MatchPhrasePrefix, "test", terms);let expected = serde_json::json!({"bool": {@@ -131,95 +129,3 @@ fn test_generate_terms_must_query() -> anyhow::Result<()> {Ok(())}--#[test]-fn test_create_query_unified_name() -> anyhow::Result<()> {- let field = "test";- let term = "test";- let query_key = QueryKey::MatchPhrase;-- let expected = serde_json::json!({- "bool": {- "minimum_should_match": 1,- "should": [- {- "match_phrase_prefix": {- "test": {- "query": "test",- "boost": 1000.0- }- }- },- {- "match": {- "test": {- "boost": 0.1,- "minimum_should_match": "80%",- "query": "test"- }- }- }- ]- }- });-- let result = create_query(CreateQueryParams {- query_key,- field,- term,- unified_params: Some(&CreateQueryUnifiedParams {- name_or_content: NameOrContent::Name,- }),- })- .to_json();-- assert_eq!(result, expected);-- Ok(())-}--#[test]-fn test_create_query_unified_content() -> anyhow::Result<()> {- let field = "test";- let term = "test";- let query_key = QueryKey::MatchPhrase;-- let expected = serde_json::json!({- "bool": {- "minimum_should_match": 1,- "should": [- {- "match_phrase_prefix": {- "test": {- "query": "test",- "boost": 900.0- }- }- },- {- "match": {- "test": {- "boost": 0.09,- "minimum_should_match": "1",- "query": "test"- }- }- }- ]- }- });-- let result = create_query(CreateQueryParams {- query_key,- field,- term,- unified_params: Some(&CreateQueryUnifiedParams {- name_or_content: NameOrContent::Content,- }),- })- .to_json();-- assert_eq!(result, expected);-- Ok(())-}diff --git a/rust/cloud-storage/opensearch_client/src/search/unified.rs b/rust/cloud-storage/opensearch_client/src/search/unified.rsindex 0d5bad1cee..b46d4eb83e 100644--- a/rust/cloud-storage/opensearch_client/src/search/unified.rs+++ b/rust/cloud-storage/opensearch_client/src/search/unified.rs@@ -26,10 +26,19 @@ use chrono::{DateTime, Utc};use models_search_cursor::{SearchCursorOption, SearchMethodCursor};use tracing::Instrument;-use crate::SearchOn;use models_opensearch::SearchEntityType;use opensearch_query_builder::*;+impl UnifiedSearchArgs {+ /// Builds the OpenSearch query JSON for this set of search args.+ pub fn to_query_json(&self) -> Result<serde_json::Value> {+ let mut json = build_unified_search_request(self)?.to_json();+ inject_fragment_size(&mut json, 1000);+ exclude_source_content(&mut json);+ Ok(json)+ }+}+#[derive(Debug, Default, Clone)]pub struct UnifiedSearchArgs {pub terms: Vec<String>,@@ -37,9 +46,7 @@ pub struct UnifiedSearchArgs {pub page: u32,pub page_size: u32,pub match_type: String,- pub search_on: SearchOn,pub collapse: bool,- pub disable_recency: bool,/// The cursor to usepub cursor: SearchCursorOption,/// The indices to search over@@ -62,9 +69,7 @@ impl From<UnifiedSearchArgs> for DocumentSearchArgs {page: args.page,page_size: args.page_size,match_type: args.match_type,- search_on: args.search_on,collapse: args.collapse,- disable_recency: args.disable_recency,ids_only: args.document_search_args.ids_only,document_ids: args.document_search_args.document_ids,}@@ -79,10 +84,8 @@ impl From<UnifiedSearchArgs> for EmailSearchArgs {page: args.page,page_size: args.page_size,match_type: args.match_type,- search_on: args.search_on,collapse: args.collapse,ids_only: false, // Email is never ids only at the moment- disable_recency: args.disable_recency,thread_ids: args.email_search_args.thread_ids,link_ids: args.email_search_args.link_ids,sender: args.email_search_args.sender,@@ -104,10 +107,8 @@ impl From<UnifiedSearchArgs> for ChannelMessageSearchArgs {page: args.page,page_size: args.page_size,match_type: args.match_type,- search_on: args.search_on,collapse: args.collapse,ids_only: true, // channel messages are always ids only- disable_recency: args.disable_recency,channel_ids: args.channel_message_search_args.channel_ids,thread_ids: args.channel_message_search_args.thread_ids,mentions: args.channel_message_search_args.mentions,@@ -124,9 +125,7 @@ impl From<UnifiedSearchArgs> for ChatSearchArgs {page: args.page,page_size: args.page_size,match_type: args.match_type,- search_on: args.search_on,collapse: args.collapse,- disable_recency: args.disable_recency,ids_only: args.chat_search_args.ids_only,chat_ids: args.chat_search_args.chat_ids,role: args.chat_search_args.role,@@ -350,11 +349,6 @@ fn build_unified_search_request(args: &UnifiedSearchArgs) -> Result<SearchRequesSearchCursorOption::Done => return Err(OpensearchClientError::SearchWithExhaustedCursor),};- // We don't support name search in opensearch- if let SearchOn::Name = args.search_on {- return Err(OpensearchClientError::InvalidSearchOn);- }-if args.search_indices.is_empty() {return Err(OpensearchClientError::EmptySearchIndices);}@@ -380,9 +374,7 @@ fn build_unified_search_request(args: &UnifiedSearchArgs) -> Result<SearchRequesbool_query.should(query_type.to_owned());}- // We can only search over channels if we are not explicitly searching by name- if args.search_indices.contains(&SearchEntityType::Channels) && args.search_on != SearchOn::Name- {+ if args.search_indices.contains(&SearchEntityType::Channels) {let channel_message_search_args: ChannelMessageSearchArgs = args.clone().into();let channel_message_query_builder: ChannelMessageQueryBuilder =channel_message_search_args.into();diff --git a/rust/cloud-storage/opensearch_client/src/search/unified/test.rs b/rust/cloud-storage/opensearch_client/src/search/unified/test.rsindex 4fdccc5db7..cde17a0da5 100644--- a/rust/cloud-storage/opensearch_client/src/search/unified/test.rs+++ b/rust/cloud-storage/opensearch_client/src/search/unified/test.rs@@ -400,18 +400,6 @@ fn test_deserialization() -> anyhow::Result<()> {Ok(())}-#[test]-fn test_fail_on_name_search() {- let err = build_unified_search_request(&UnifiedSearchArgs {- search_on: SearchOn::Name,- ..Default::default()- })- .err()- .unwrap();-- assert_eq!(err, OpensearchClientError::InvalidSearchOn);-}-#[test]fn test_build_unified_search_request_content() -> anyhow::Result<()> {let entity_id = uuid::Uuid::new_v4();@@ -432,9 +420,8 @@ fn test_build_unified_search_request_content() -> anyhow::Result<()> {page: 1,page_size: 20,match_type: "exact".to_string(),- search_on: SearchOn::Content,+collapse: true,- disable_recency: false,document_search_args: UnifiedDocumentSearchArgs {document_ids: vec!["id1".to_string(), "id2".to_string()],ids_only: false,@@ -802,9 +789,8 @@ fn test_build_unified_search_request_content() -> anyhow::Result<()> {page: 1,page_size: 20,match_type: "exact".to_string(),- search_on: SearchOn::NameContent,+collapse: true,- disable_recency: false,document_search_args: UnifiedDocumentSearchArgs {document_ids: vec!["id1".to_string(), "id2".to_string()],ids_only: false,@@ -851,9 +837,8 @@ fn test_build_unified_search_request_single_index() -> anyhow::Result<()> {page: 1,page_size: 20,match_type: "exact".to_string(),- search_on: SearchOn::Content,+collapse: true,- disable_recency: false,document_search_args: UnifiedDocumentSearchArgs {document_ids: vec!["id1".to_string(), "id2".to_string()],ids_only: false,diff --git a/rust/cloud-storage/opensearch_client/src/search_on.rs b/rust/cloud-storage/opensearch_client/src/search_on.rsdeleted file mode 100644index dff6f7aa4a..0000000000--- a/rust/cloud-storage/opensearch_client/src/search_on.rs+++ /dev/null@@ -1,31 +0,0 @@-/// Defines which fields to search on-#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]-pub enum SearchOn {- /// Search only on the name/title field- Name,- /// Search only on the content field- #[default]- Content,- /// Search on both name and content fields (not yet implemented)- NameContent,-}--#[derive(Debug, Clone, Copy, PartialEq, Eq)]-pub enum NameOrContent {- Name,- Content,-}--impl TryFrom<SearchOn> for NameOrContent {- type Error = anyhow::Error;-- fn try_from(value: SearchOn) -> Result<Self, Self::Error> {- match value {- SearchOn::Name => Ok(Self::Name),- SearchOn::Content => Ok(Self::Content),- SearchOn::NameContent => Err(anyhow::anyhow!(- "NameContent is not a valid value for NameOrContent"- )),- }- }-}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.rsindex 44ecaea64a..77686aad5b 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@@ -141,7 +141,6 @@ pub(in crate::api::search) async fn perform_unified_search(}let match_type = req.match_type;- let disable_recency = req.disable_recency;let include = req.include;let filters = req.filters.unwrap_or_default();@@ -247,9 +246,7 @@ pub(in crate::api::search) async fn perform_unified_search(page_size,cursor: content_cursor_for_search,match_type: match_type.to_string(),- search_on: search_on.into(),collapse,- disable_recency,search_indices: generate_unified_search_indices(include),document_search_args: filter_document_response.clone(),email_search_args: filter_email_response.clone(),