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 names index (#930)
Will Hutchinson5ef2b2939d16
diff --git a/infra/stacks/opensearch/helpers/constants.ts b/infra/stacks/opensearch/helpers/constants.tsindex 9ce4665673..71ed5aab43 100644--- a/infra/stacks/opensearch/helpers/constants.ts+++ b/infra/stacks/opensearch/helpers/constants.ts@@ -2,9 +2,8 @@ const CHAT_INDEX = 'chats';const DOCUMENT_INDEX = 'documents';const EMAIL_INDEX = 'emails';const CHANNEL_INDEX = 'channels';-const NAMES_INDEX = 'names';-export { CHAT_INDEX, DOCUMENT_INDEX, EMAIL_INDEX, CHANNEL_INDEX, NAMES_INDEX };+export { CHAT_INDEX, DOCUMENT_INDEX, EMAIL_INDEX, CHANNEL_INDEX };export const SHARD_SETTINGS =process.env.ENVIRONMENT === 'prod'diff --git a/infra/stacks/opensearch/helpers/scripts/create_indices.ts b/infra/stacks/opensearch/helpers/scripts/create_indices.tsindex 359df77f83..eb227bb216 100644--- a/infra/stacks/opensearch/helpers/scripts/create_indices.ts+++ b/infra/stacks/opensearch/helpers/scripts/create_indices.ts@@ -5,60 +5,9 @@ import {CHAT_INDEX,DOCUMENT_INDEX,EMAIL_INDEX,- NAMES_INDEX,SHARD_SETTINGS,} from '../constants';-async function createNamesIndex(opensearchClient: Client) {- const namesIndexExists = (- await opensearchClient.indices.exists({- index: NAMES_INDEX,- })- ).body;- if (!namesIndexExists) {- console.log(`${NAMES_INDEX} index does not exist, creating...`);-- opensearchClient.indices.create({- index: NAMES_INDEX,- body: {- settings: {- ...SHARD_SETTINGS,- },- mappings: {- properties: {- // The id of the entity- entity_id: {- type: 'keyword',- },- // The name of the entity- name: {- type: 'text',- fields: {- keyword: {- type: 'keyword',- ignore_above: 128,- },- },- },- // The type of the entity- entity_type: {- type: 'keyword',- },- // The user id of who created the entity- user_id: {- type: 'keyword',- index: true,- doc_values: true,- },- },- },- },- });- } else {- console.log(`${NAMES_INDEX} index already exists`);- }-}-async function createChannelIndex(opensearchClient: Client) {const channelIndexExists = (await opensearchClient.indices.exists({@@ -375,7 +324,6 @@ async function createIndices() {await createChatIndex(opensearchClient);await createEmailIndex(opensearchClient);await createChannelIndex(opensearchClient);- await createNamesIndex(opensearchClient);console.log('done');} catch (error) {console.error('Error', error);diff --git a/infra/stacks/opensearch/helpers/scripts/delete_user_entities.ts b/infra/stacks/opensearch/helpers/scripts/delete_user_entities.tsindex 6d694b691a..970fa41eff 100644--- a/infra/stacks/opensearch/helpers/scripts/delete_user_entities.ts+++ b/infra/stacks/opensearch/helpers/scripts/delete_user_entities.ts@@ -1,5 +1,4 @@import { client } from '../client';-import { NAMES_INDEX } from '../constants';/*** Delete User Entities Script@@ -129,65 +128,6 @@ async function deleteUserData() {`Deleted ${deletedCount} documents from ${index} (${remainingCount} remaining)`);}-- // Delete corresponding entries from names index- console.log(- `Deleting entries from ${NAMES_INDEX} for entity_type: ${index} and user_id: ${userId}`- );-- const namesQuery = {- bool: {- must: [- {- term: {- entity_type: index,- },- },- {- term: {- user_id: userId,- },- },- ],- },- };-- // Count names entries before deletion- const namesCountResult = await opensearchClient.count({- index: NAMES_INDEX,- body: {- query: namesQuery,- },- });-- const namesDocCount = namesCountResult.body.count;- console.log(- `Found ${namesDocCount} entries in ${NAMES_INDEX} for entity_type: ${index} and user_id: ${userId}`- );-- if (namesDocCount > 0) {- await opensearchClient.deleteByQuery({- index: NAMES_INDEX,- body: {- query: namesQuery,- },- refresh: true,- });-- // Verify names deletion- const namesVerifyResult = await opensearchClient.count({- index: NAMES_INDEX,- body: {- query: namesQuery,- },- });-- const namesRemainingCount = namesVerifyResult.body.count;- const namesDeletedCount = namesDocCount - namesRemainingCount;- console.log(- `Deleted ${namesDeletedCount} entries from ${NAMES_INDEX} (${namesRemainingCount} remaining)`- );- }}console.log('User data deletion completed');diff --git a/rust/cloud-storage/comms_service/src/api/channels/create_channel.rs b/rust/cloud-storage/comms_service/src/api/channels/create_channel.rsindex e923f65845..aefd69d40f 100644--- a/rust/cloud-storage/comms_service/src/api/channels/create_channel.rs+++ b/rust/cloud-storage/comms_service/src/api/channels/create_channel.rs@@ -8,10 +8,7 @@ use axum::{use comms_db_client::channels::create_channel::{CreateChannelOptions, create_channel};use model::comms::ChannelType;use model::user::UserContext;-use models_opensearch::SearchEntityType;use serde::{Deserialize, Serialize};-use sqs_client::search::{SearchQueueMessage, name::EntityName};-use tracing::Instrument;use utoipa::ToSchema;#[derive(Debug, Serialize, Deserialize, ToSchema)]@@ -114,29 +111,6 @@ pub async fn create_channel_handler(})?;}- if req.name.is_some() {- tokio::spawn({- let sqs_client = ctx.sqs_client.clone();- let channel_id = id;- async move {- tracing::trace!("sending message to search extractor queue");-- let _ = sqs_client- .send_message_to_search_event_queue(SearchQueueMessage::UpdateEntityName(- EntityName {- entity_id: channel_id,- entity_type: SearchEntityType::Channels,- },- ))- .await- .inspect_err(|e| {- tracing::error!(error=?e, "SEARCH_QUEUE unable to enqueue message");- });- }- .in_current_span()- });- }-Ok((StatusCode::OK,Json(CreateChannelResponse { id: id.to_string() }),diff --git a/rust/cloud-storage/comms_service/src/api/channels/delete_channel.rs b/rust/cloud-storage/comms_service/src/api/channels/delete_channel.rsindex a353ac7cc3..dbb5bc2127 100644--- a/rust/cloud-storage/comms_service/src/api/channels/delete_channel.rs+++ b/rust/cloud-storage/comms_service/src/api/channels/delete_channel.rs@@ -45,11 +45,6 @@ pub async fn delete_channel_handler(None::<&str>,);- service::search::send_remove_channel_name_to_search_extractor_queue(- &ctx.sqs_client,- &channel_id,- );-Ok((StatusCode::NOT_FOUND,"channel successfully deleted".to_string(),diff --git a/rust/cloud-storage/comms_service/src/api/channels/patch_channel.rs b/rust/cloud-storage/comms_service/src/api/channels/patch_channel.rsindex 35cd46603e..4f027529d6 100644--- a/rust/cloud-storage/comms_service/src/api/channels/patch_channel.rs+++ b/rust/cloud-storage/comms_service/src/api/channels/patch_channel.rs@@ -6,8 +6,6 @@ use anyhow::Result;use axum::{Json, extract::State, http::StatusCode};use axum_extra::extract::Cached;use comms_db_client::channels::patch_channel::{self, PatchChannelOptions};-use models_opensearch::SearchEntityType;-use tracing::Instrument;#[utoipa::path(patch,@@ -41,8 +39,6 @@ pub async fn patch_channel_handler());}- let name = req.channel_name.clone();-patch_channel::patch_channel(&ctx.db, &channel_id, &channel_owner.context.user_id, req).await.map_err(|e| {@@ -54,30 +50,5 @@ pub async fn patch_channel_handler()})?;- if name.is_some() {- tokio::spawn({- let sqs_client = ctx.sqs_client.clone();- let channel_id = channel_id;- async move {- tracing::trace!("sending message to search extractor queue");-- let _ = sqs_client- .send_message_to_search_event_queue(- sqs_client::search::SearchQueueMessage::UpdateEntityName(- sqs_client::search::name::EntityName {- entity_id: channel_id,- entity_type: SearchEntityType::Channels,- },- ),- )- .await- .inspect_err(|e| {- tracing::error!(error=?e, "SEARCH_QUEUE unable to enqueue message");- });- }- .in_current_span()- });- }-Ok((StatusCode::OK, "patched channel".to_string()))}diff --git a/rust/cloud-storage/comms_service/src/service/search.rs b/rust/cloud-storage/comms_service/src/service/search.rsindex e3838aabba..0587314b73 100644--- a/rust/cloud-storage/comms_service/src/service/search.rs+++ b/rust/cloud-storage/comms_service/src/service/search.rs@@ -73,37 +73,3 @@ pub fn send_remove_channel_message_to_search_extractor_queue(});}}--#[tracing::instrument(skip(sqs_client))]-pub fn send_remove_channel_name_to_search_extractor_queue(- sqs_client: &sqs_client::SQS,- channel_id: &uuid::Uuid,-) {- #[cfg(feature = "channel_search")]- {- use tracing::Instrument;-- tracing::trace!("enqueueing message to search");-- tokio::spawn({- let sqs_client = sqs_client.clone();- let channel_id = *channel_id;- async move {- let _ = sqs_client- .send_message_to_search_event_queue(- sqs_client::search::SearchQueueMessage::RemoveEntityName(- sqs_client::search::name::EntityName {- entity_id: channel_id,- entity_type: models_opensearch::SearchEntityType::Channels,- },- ),- )- .await- .inspect_err(|e| {- tracing::error!(error=?e, "SEARCH_QUEUE unable to enqueue message");- });- }- .in_current_span()- });- }-}diff --git a/rust/cloud-storage/document_cognition_service/src/api/chats/create_user_chat.rs b/rust/cloud-storage/document_cognition_service/src/api/chats/create_user_chat.rsindex 371c1f6c25..ba6bfc20e2 100644--- a/rust/cloud-storage/document_cognition_service/src/api/chats/create_user_chat.rs+++ b/rust/cloud-storage/document_cognition_service/src/api/chats/create_user_chat.rs@@ -25,8 +25,6 @@ use model::{chat::AttachmentType, response::StringIDResponse};use model::{chat::NewChatAttachment, user::axum_extractor::MacroUserExtractor};use models_permissions::share_permission::SharePermissionV2;use models_permissions::share_permission::access_level::EditAccessLevel;-use sqs_client::search::SearchQueueMessage;-use tracing::Instrument;#[utoipa::path(post,@@ -179,33 +177,5 @@ pub async fn create_user_chat_v2().await;- tokio::spawn({- let sqs_client = ctx.sqs_client.clone();- let chat_id = chat.clone();- async move {- tracing::trace!("sending message to search extractor queue");- let chat_id = match macro_uuid::string_to_uuid(&chat_id) {- Ok(chat_id) => chat_id,- Err(err) => {- tracing::error!(error=?err, "failed to convert chat_id to uuid");- return;- }- };-- let _ = sqs_client- .send_message_to_search_event_queue(SearchQueueMessage::UpdateEntityName(- sqs_client::search::name::EntityName {- entity_id: chat_id,- entity_type: models_opensearch::SearchEntityType::Chats,- },- ))- .await- .inspect_err(|e| {- tracing::error!(error=?e, "SEARCH_QUEUE unable to enqueue message");- });- }- .in_current_span()- });-Ok(StringIDResponse { id: chat })}diff --git a/rust/cloud-storage/document_cognition_service/src/api/chats/patch_chat.rs b/rust/cloud-storage/document_cognition_service/src/api/chats/patch_chat.rsindex 913ef13287..e3651bdee8 100644--- a/rust/cloud-storage/document_cognition_service/src/api/chats/patch_chat.rs+++ b/rust/cloud-storage/document_cognition_service/src/api/chats/patch_chat.rs@@ -117,30 +117,6 @@ async fn patch_chat_v2().await;- if req.name.is_some() {- match macro_uuid::string_to_uuid(&chat_id) {- Ok(chat_id) => {- let _ = ctx- .sqs_client- .send_message_to_search_event_queue(- sqs_client::search::SearchQueueMessage::UpdateEntityName(- sqs_client::search::name::EntityName {- entity_id: chat_id,- entity_type: models_opensearch::SearchEntityType::Chats,- },- ),- )- .await- .inspect_err(|e| {- tracing::error!(error=?e, "SEARCH_QUEUE unable to enqueue message");- });- }- Err(err) => {- tracing::error!(error=?err, "failed to convert chat_id to uuid");- }- }- }-Ok(())}diff --git a/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rsindex 564b2024aa..8da28364ad 100644--- a/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rs+++ b/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rs@@ -26,9 +26,6 @@ use ai_tools::{AiToolSet, RequestContext, ToolServiceContext};use anyhow::{Context, Result};use futures::stream::StreamExt;use model::chat::{NewAttachment, NewChatMessage};-use models_opensearch::SearchEntityType;-use sqs_client::search::SearchQueueMessage;-use sqs_client::search::name::EntityName;use std::sync::Arc;use tokio;use tokio::sync::mpsc::UnboundedSender;@@ -389,21 +386,6 @@ pub async fn handle_send_chat_message(},)});-- // Send the message to the search event queue for setting chat name- match macro_uuid::string_to_uuid(&incoming_message.chat_id) {- Ok(chat_id) => {- let _ = ctx.sqs_client.send_message_to_search_event_queue(- SearchQueueMessage::UpdateEntityName(EntityName {- entity_id: chat_id,- entity_type: SearchEntityType::Chats,- }),- ).await.inspect_err(|err| tracing::error!(error=?err, "failed to send message to search event queue"));- }- Err(err) => {- tracing::error!(error=?err, "failed to convert chat_id to uuid");- }- }}Ok(())}diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/create_document/create_document_handler.rs b/rust/cloud-storage/document_storage_service/src/api/documents/create_document/create_document_handler.rsindex c4bc273896..a4d52f687d 100644--- a/rust/cloud-storage/document_storage_service/src/api/documents/create_document/create_document_handler.rs+++ b/rust/cloud-storage/document_storage_service/src/api/documents/create_document/create_document_handler.rs@@ -113,15 +113,6 @@ pub(in crate::api) async fn create_document_handler(}};- utils::notify_search_service_of_document_name_update(- state.sqs_client.clone(),- response_data- .document_response- .document_metadata- .document_id- .clone(),- );-return GenericResponse::builder().data(&response_data).send(StatusCode::OK);diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/create_task.rs b/rust/cloud-storage/document_storage_service/src/api/documents/create_task.rsindex 3993d05309..3f96d02f2f 100644--- a/rust/cloud-storage/document_storage_service/src/api/documents/create_task.rs+++ b/rust/cloud-storage/document_storage_service/src/api/documents/create_task.rs@@ -150,10 +150,5 @@ pub(in crate::api) async fn create_task_handler(}}- utils::notify_search_service_of_document_name_update(- state.sqs_client.clone(),- document_id.clone(),- );-Ok(Json(CreateTaskResponse { document_id }))}diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/edit_document/edit_document_v2.rs b/rust/cloud-storage/document_storage_service/src/api/documents/edit_document/edit_document_v2.rsindex 91b958b6bc..46c899c54f 100644--- a/rust/cloud-storage/document_storage_service/src/api/documents/edit_document/edit_document_v2.rs+++ b/rust/cloud-storage/document_storage_service/src/api/documents/edit_document/edit_document_v2.rs@@ -1,7 +1,4 @@-use crate::{- api::{context::ApiContext, documents::utils},- model::request::documents::edit::EditDocumentRequestV2,-};+use crate::{api::context::ApiContext, model::request::documents::edit::EditDocumentRequestV2};use anyhow::Context;use axum::{http::StatusCode,@@ -82,14 +79,6 @@ pub async fn edit_document().await;- // If an important attribute is updated we will need to send a message to the search extractor- if document_name.is_some() {- utils::notify_search_service_of_document_name_update(- ctx.sqs_client.clone(),- document_context.document_id.clone(),- );- }-Ok((StatusCode::OK,Json(SuccessResponse {diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/utils/mod.rs b/rust/cloud-storage/document_storage_service/src/api/documents/utils/mod.rsindex 7b9dd54ccc..59b9ad1f04 100644--- a/rust/cloud-storage/document_storage_service/src/api/documents/utils/mod.rs+++ b/rust/cloud-storage/document_storage_service/src/api/documents/utils/mod.rs@@ -1,9 +1,7 @@use std::sync::Arc;-use models_opensearch::SearchEntityType;use sqlx::{PgPool, Pool, Postgres};-use sqs_client::search::{SearchQueueMessage, name::EntityName};-use tracing::{Instrument, instrument};+use tracing::instrument;use crate::service::s3::S3;@@ -52,36 +50,3 @@ pub(in crate::api::documents) async fn cleanup_document_version_on_error(.await.map_err(|e| tracing::error!(error=?e, "unable to delete document version"));}--/// Notifies the search service of a document name update by sending a message to the search event queue-#[instrument(skip(sqs_client), fields(document_id = %document_id))]-pub(in crate::api::documents) fn notify_search_service_of_document_name_update(- sqs_client: Arc<sqs_client::SQS>,- document_id: String,-) {- tokio::spawn(- async move {- tracing::trace!("sending message to search extractor queue");- let document_id = match macro_uuid::string_to_uuid(&document_id) {- Ok(document_id) => document_id,- Err(err) => {- tracing::error!(error=?err, "failed to convert document_id to uuid");- return;- }- };-- let _ = sqs_client- .send_message_to_search_event_queue(SearchQueueMessage::UpdateEntityName(- EntityName {- entity_id: document_id,- entity_type: SearchEntityType::Documents,- },- ))- .await- .inspect_err(|e| {- tracing::error!(error=?e, "SEARCH_QUEUE unable to enqueue message");- });- }- .in_current_span(),- );-}diff --git a/rust/cloud-storage/email_service/src/api/email/drafts/delete.rs b/rust/cloud-storage/email_service/src/api/email/drafts/delete.rsindex 120da8dca9..427a4f3a67 100644--- a/rust/cloud-storage/email_service/src/api/email/drafts/delete.rs+++ b/rust/cloud-storage/email_service/src/api/email/drafts/delete.rs@@ -6,9 +6,6 @@ use axum::response::{IntoResponse, Response};use email_service::util::gmail::send::cleanup_draft_attachments;use model::response::{EmptyResponse, ErrorResponse};use models_email::service::link::Link;-use models_opensearch::SearchEntityType;-use sqs_client::search::SearchQueueMessage;-use sqs_client::search::name::EntityName;use strum_macros::AsRefStr;use thiserror::Error;use uuid::Uuid;@@ -102,7 +99,7 @@ pub async fn handler(.await;match result {- Ok(deleted_thread) => {+ Ok(_deleted_thread) => {tx.commit().await?;// cleanup attachments in the background@@ -124,23 +121,6 @@ pub async fn handler(});}- if let Some(thread_id) = deleted_thread {- tokio::spawn(async move {- let _ = ctx- .sqs_client- .send_message_to_search_event_queue(SearchQueueMessage::RemoveEntityName(- EntityName {- entity_id: thread_id,- entity_type: SearchEntityType::Emails,- },- ))- .await- .inspect_err(|e| {- tracing::error!(error=?e, "failed to send message to search extractor queue");- });- });- }-Ok(StatusCode::NO_CONTENT.into_response())}Err(e) => {diff --git a/rust/cloud-storage/email_service/src/pubsub/backfill/update_metadata.rs b/rust/cloud-storage/email_service/src/pubsub/backfill/update_metadata.rsindex 178c3d736e..2ef27e0db0 100644--- a/rust/cloud-storage/email_service/src/pubsub/backfill/update_metadata.rs+++ b/rust/cloud-storage/email_service/src/pubsub/backfill/update_metadata.rs@@ -3,10 +3,8 @@ use crate::pubsub::context::PubSubContext;use models_email::email::service::backfill::{BackfillPubsubMessage, UpdateMetadataPayload};use models_email::email::service::link;use models_email::email::service::pubsub::{DetailedError, FailureReason, ProcessingError};-use models_opensearch::SearchEntityType;use sqs_client::search::SearchQueueMessage;use sqs_client::search::email::EmailThreadMessage;-use sqs_client::search::name::EntityName;/// This step is invoked by BackfillMessage once all messages in a thread have been backfilled./// Updates the thread metadata in the database, the replying_to_id values of its messages, and@@ -98,19 +96,5 @@ pub async fn update_thread_metadata(})})?;- // notify search about new entity- ctx.sqs_client- .send_message_to_search_event_queue(SearchQueueMessage::UpdateEntityName(EntityName {- entity_id: p.thread_db_id,- entity_type: SearchEntityType::Emails,- }))- .await- .map_err(|e| {- ProcessingError::NonRetryable(DetailedError {- reason: FailureReason::SqsEnqueueFailed,- source: e.context("Failed to send message to search extractor queue"),- })- })?;-Ok(())}diff --git a/rust/cloud-storage/email_service/src/pubsub/inbox_sync/operations/delete_message.rs b/rust/cloud-storage/email_service/src/pubsub/inbox_sync/operations/delete_message.rsindex 88b79761c0..e5d5f9c36d 100644--- a/rust/cloud-storage/email_service/src/pubsub/inbox_sync/operations/delete_message.rs+++ b/rust/cloud-storage/email_service/src/pubsub/inbox_sync/operations/delete_message.rs@@ -3,10 +3,8 @@ use crate::pubsub::util::{cg_refresh_email, complete_transaction_with_processinguse models_email::email::service::link;use models_email::gmail::inbox_sync::DeleteMessagePayload;use models_email::service::pubsub::{DetailedError, FailureReason, ProcessingError};-use models_opensearch::SearchEntityType;use sqs_client::search::SearchQueueMessage;use sqs_client::search::email::EmailMessage;-use sqs_client::search::name::EntityName;use std::result;use uuid::Uuid;@@ -58,27 +56,6 @@ pub async fn delete_message(}.await;- if let Ok(deleted_thread) = result- && let Some(thread_id) = deleted_thread- {- let sqs_client = ctx.sqs_client.clone();- tokio::spawn({- async move {- let _ = sqs_client- .send_message_to_search_event_queue(SearchQueueMessage::RemoveEntityName(- EntityName {- entity_id: thread_id,- entity_type: SearchEntityType::Emails,- },- ))- .await- .inspect_err(|e| {- tracing::error!(error=?e, "failed to send message to search extractor queue");- });- }- });- }-complete_transaction_with_processing_error(tx, result).await?;// tell FE to refresh user's inboxdiff --git a/rust/cloud-storage/email_service/src/pubsub/inbox_sync/operations/upsert_message.rs b/rust/cloud-storage/email_service/src/pubsub/inbox_sync/operations/upsert_message.rsindex 505b90a890..54a5393330 100644--- a/rust/cloud-storage/email_service/src/pubsub/inbox_sync/operations/upsert_message.rs+++ b/rust/cloud-storage/email_service/src/pubsub/inbox_sync/operations/upsert_message.rs@@ -20,9 +20,6 @@ use models_email::gmail::operations::GmailApiOperation;use models_email::service::attachment::{AttachmentUploadArgs, AttachmentUploadDestination};use models_email::service::message::Message;use models_email::service::pubsub::{DetailedError, FailureReason, ProcessingError};-use models_opensearch::SearchEntityType;-use sqs_client::search::SearchQueueMessage;-use sqs_client::search::name::EntityName;use std::collections::HashSet;use std::result;use uuid::Uuid;@@ -398,7 +395,7 @@ async fn fetch_and_insert_thread(// insert threads into dbfor thread in threads.into_iter() {- let thread_id = threads::insert::insert_thread_and_messages(&ctx.db, thread, link_id)+ threads::insert::insert_thread_and_messages(&ctx.db, thread, link_id).await.map_err(|e| {ProcessingError::Retryable(DetailedError {@@ -406,20 +403,6 @@ async fn fetch_and_insert_thread(source: e.context("Failed to insert thread and messages".to_string()),})})?;-- // when a thread is created, add an entry into the names index for it- ctx.sqs_client- .send_message_to_search_event_queue(SearchQueueMessage::UpdateEntityName(EntityName {- entity_id: thread_id,- entity_type: SearchEntityType::Emails,- }))- .await- .map_err(|e| {- ProcessingError::NonRetryable(DetailedError {- reason: FailureReason::SqsEnqueueFailed,- source: e.context("Failed to send message to search extractor queue"),- })- })?;}Ok(())diff --git a/rust/cloud-storage/search_processing_service/Cargo.toml b/rust/cloud-storage/search_processing_service/Cargo.tomlindex d7b40e69e7..bc0b69298d 100644--- a/rust/cloud-storage/search_processing_service/Cargo.toml+++ b/rust/cloud-storage/search_processing_service/Cargo.toml@@ -6,7 +6,6 @@ publish = falseversion = "0.1.0"[features]-backfill_names = ["comms_db_client", "email_db_client"]default = ["processing", "service"]processing = []service = ["macro_db_client"]@@ -16,11 +15,6 @@ name = "backfill_chat"path = "src/bin/backfill_chat.rs"required-features = ["service"]-[[bin]]-name = "backfill_entity_names"-path = "src/bin/backfill_entity_names.rs"-required-features = ["backfill_names"]-[[bin]]name = "search_processing_service"path = "src/main.rs"diff --git a/rust/cloud-storage/search_processing_service/src/bin/backfill_entity_names.rs b/rust/cloud-storage/search_processing_service/src/bin/backfill_entity_names.rsdeleted file mode 100644index 3cd4b480f5..0000000000--- a/rust/cloud-storage/search_processing_service/src/bin/backfill_entity_names.rs+++ /dev/null@@ -1,250 +0,0 @@-/// backfill_entity_names.rs is used to trigger a backfill for the entity name index in OS-/// Required environment variables:-/// - DATABASE_URL-/// - SEARCH_EVENT_QUEUE-///-/// Usage:-/// cargo run backfill_entity_names.rs <COMMA_SEPARATED_LIST_OF_INDICES>-/// Example:-/// cargo run backfill_entity_names.rs chats,documents-use anyhow::Context;--use macro_entrypoint::MacroEntrypoint;-use models_opensearch::SearchEntityType;-use sqlx::postgres::PgPoolOptions;-use sqs_client::search::name::EntityName;-use std::future::Future;-use std::str::FromStr;-use std::sync::Arc;-use uuid::Uuid;--#[tokio::main]-async fn main() -> anyhow::Result<()> {- MacroEntrypoint::default().init();-- // 1. Parse CLI Arguments- let args: Vec<String> = std::env::args().collect();-- let target_indices: Vec<SearchEntityType> = if args.len() < 2 {- // Default to all supported entity types- println!("No indices specified, backfilling all supported types");- vec![- SearchEntityType::Chats,- SearchEntityType::Documents,- SearchEntityType::Channels,- SearchEntityType::Emails,- // Note: Projects is not included as it's not implemented- ]- } else {- let indices_arg = &args[1];- indices_arg- .split(',')- .map(|s| {- // Trim whitespace and parse using strum::EnumString derived on SearchEntityType- SearchEntityType::from_str(s.trim())- .with_context(|| format!("Invalid entity index type: {}", s))- })- .collect::<anyhow::Result<_>>()?- };-- if target_indices.is_empty() {- println!("No valid indices provided to process.");- return Ok(());- }-- // Check if user is trying to backfill Projects- if target_indices.contains(&SearchEntityType::Projects) {- anyhow::bail!(- "Backfill for 'projects' is not implemented. Supported types: chats, documents, channels, emails"- );- }-- println!("Starting backfill for indices: {:?}", target_indices);-- let database_url = std::env::var("DATABASE_URL").context("DATABASE_URL not set")?;- let db = Arc::new(- PgPoolOptions::new()- .min_connections(10)- .max_connections(60)- .connect(&database_url)- .await?,- );-- let search_event_queue =- std::env::var("SEARCH_EVENT_QUEUE").context("SEARCH_EVENT_QUEUE not set")?;-- let queue_aws_config = aws_config::defaults(aws_config::BehaviorVersion::latest())- .region("us-east-1")- .load()- .await;-- let sqs_client = Arc::new(- sqs_client::SQS::new(aws_sdk_sqs::Client::new(&queue_aws_config))- .search_event_queue(&search_event_queue),- );-- // Process all entity types in parallel- let handles: Vec<_> = target_indices- .into_iter()- .map(|index| {- let db = Arc::clone(&db);- let sqs_client = Arc::clone(&sqs_client);-- tokio::spawn(async move {- let result = match index {- SearchEntityType::Chats => {- backfill_entities(- &sqs_client,- "chats",- SearchEntityType::Chats,- |limit, offset| {- let db = Arc::clone(&db);- async move {- macro_db_client::chat::get::get_all_chat_ids_paginated(- &db, limit, offset,- )- .await- }- },- )- .await- }- SearchEntityType::Documents => {- backfill_entities(- &sqs_client,- "documents",- SearchEntityType::Documents,- |limit, offset| {- let db = Arc::clone(&db);- async move {- macro_db_client::document::get_all_documents::get_all_document_ids_paginated(- &db, limit, offset,- )- .await- }- },- )- .await- }- SearchEntityType::Channels => {- backfill_entities(- &sqs_client,- "channels",- SearchEntityType::Channels,- |limit, offset| {- let db = Arc::clone(&db);- async move {- comms_db_client::channels::get_channels::get_all_channel_ids_paginated(- &db, limit, offset,- )- .await- }- },- )- .await- }- SearchEntityType::Emails => {- backfill_entities(- &sqs_client,- "email threads",- SearchEntityType::Emails,- |limit, offset| {- let db = Arc::clone(&db);- async move {- email_db_client::threads::get::get_all_thread_ids_paginated(- &db, limit, offset,- )- .await- }- },- )- .await- }- SearchEntityType::Projects => {- unreachable!("Backfill logic for 'projects' is not implemented.");- }- };-- (index, result)- })- })- .collect();-- // Wait for all tasks and report results- let mut had_errors = false;- for handle in handles {- match handle.await {- Ok((index, Ok(()))) => {- println!("Successfully completed backfill for {:?}", index);- }- Ok((index, Err(e))) => {- eprintln!("Error backfilling {:?}: {:?}", index, e);- had_errors = true;- }- Err(e) => {- eprintln!("Task panicked: {:?}", e);- had_errors = true;- }- }- }-- if had_errors {- anyhow::bail!("One or more backfill tasks failed");- }-- Ok(())-}--/// Generic function to handle pagination, UUID parsing, and SQS queuing for any entity type-/// Uses concurrent batch processing for improved throughput-async fn backfill_entities<F, Fut>(- sqs_client: &sqs_client::SQS,- name: &str,- entity_type: SearchEntityType,- fetcher: F,-) -> anyhow::Result<()>-where- F: Fn(i64, i64) -> Fut + Send + Sync,- Fut: Future<Output = anyhow::Result<Vec<String>>> + Send,-{- let limit = 5000;- let mut offset = 0;- let mut count = 0;-- loop {- println!("[{}] fetching batch at offset {}", name, offset);-- let ids = fetcher(limit, offset).await?;- println!("[{}] got {} ids at offset {}", name, ids.len(), offset);-- if ids.is_empty() {- tracing::trace!("no more {name} found");- break;- }-- count += ids.len();-- let messages: Vec<_> = ids- .iter()- .map(|id| {- sqs_client::search::SearchQueueMessage::UpdateEntityName(EntityName {- entity_id: Uuid::parse_str(id)- .with_context(|| format!("Failed to parse UUID from {}: {}", name, id))- .unwrap(),- entity_type: entity_type.clone(),- })- })- .collect();-- sqs_client- .bulk_send_message_to_search_event_queue(messages)- .await?;-- println!("[{}] queued batch at offset {}", name, offset);-- offset += limit;- }-- println!("[{}] Completed. Total processed: {}", name, count);- Ok(())-}diff --git a/rust/cloud-storage/search_processing_service/src/process/mod.rs b/rust/cloud-storage/search_processing_service/src/process/mod.rsindex f5275ffc15..e44f7d7497 100644--- a/rust/cloud-storage/search_processing_service/src/process/mod.rs+++ b/rust/cloud-storage/search_processing_service/src/process/mod.rs@@ -3,7 +3,6 @@ mod chat;pub mod context;mod document;mod email;-mod name;mod user;pub mod worker;@@ -32,12 +31,6 @@ pub async fn process_message();match search_extractor_message {- SearchQueueMessage::UpdateEntityName(message) => {- name::upsert_name(&ctx.opensearch_client, &ctx.db, &message).await?;- }- SearchQueueMessage::RemoveEntityName(message) => {- name::remove_name(&ctx.opensearch_client, &message).await?;- }SearchQueueMessage::RemoveUserProfile(user_profile_id) => {tracing::trace!(user_profile_id = user_profile_id, "removing user profile");user::remove_user_profile(&ctx.opensearch_client, &user_profile_id).await?;diff --git a/rust/cloud-storage/search_processing_service/src/process/name.rs b/rust/cloud-storage/search_processing_service/src/process/name.rsdeleted file mode 100644index 6838fd48d6..0000000000--- a/rust/cloud-storage/search_processing_service/src/process/name.rs+++ /dev/null@@ -1,54 +0,0 @@-//! This module handles the processing of entity name messages--use opensearch_client::{OpensearchClient, upsert::name::UpsertEntityNameArgs};-use sqs_client::search::name::EntityName;--/// Handles upserting the name for an entity-#[tracing::instrument(skip(opensearch_client, db), err)]-pub async fn upsert_name(- opensearch_client: &OpensearchClient,- db: &sqlx::Pool<sqlx::Postgres>,- message: &EntityName,-) -> anyhow::Result<()> {- let (entity_name, user_id) = macro_db_client::entity_name::get_entity_name_and_owner(- db,- &message.entity_id,- &message.entity_type,- )- .await?;-- let name = if let Some(entity_name) = entity_name {- entity_name- } else {- return Ok(());- };-- if name.is_empty() {- return Ok(());- }-- // Perform upsert- opensearch_client- .upsert_entity_name(&UpsertEntityNameArgs {- entity_id: message.entity_id.to_string(),- name,- user_id,- entity_type: message.entity_type.clone(),- })- .await?;-- Ok(())-}--/// Handles removing the name for an entity-#[tracing::instrument(skip(opensearch_client), err)]-pub async fn remove_name(- opensearch_client: &OpensearchClient,- message: &EntityName,-) -> anyhow::Result<()> {- opensearch_client- .delete_entity_name(&message.entity_id.to_string(), &message.entity_type)- .await?;-- Ok(())-}diff --git a/rust/cloud-storage/sqs_client/src/search/mod.rs b/rust/cloud-storage/sqs_client/src/search/mod.rsindex 1d41ff3bef..3e02498168 100644--- a/rust/cloud-storage/sqs_client/src/search/mod.rs+++ b/rust/cloud-storage/sqs_client/src/search/mod.rs@@ -5,7 +5,6 @@ use crate::{chat::{ChatMessage, RemoveChatMessage},document::{DocumentId, SearchExtractorMessage},email::{EmailLinkMessage, EmailMessage, EmailThreadMessage},- name::EntityName,},};use anyhow::Context;@@ -17,7 +16,6 @@ pub mod channel;pub mod chat;pub mod document;pub mod email;-pub mod name;use crate::{MAX_BATCH_SIZE, PrimaryId};@@ -84,10 +82,6 @@ pub enum SearchQueueMessage {// UserRemoveUserProfile(String),-- // Entity Name- UpdateEntityName(EntityName),- RemoveEntityName(EntityName),}impl PrimaryId for SearchQueueMessage {@@ -113,9 +107,6 @@ impl PrimaryId for SearchQueueMessage {}SearchQueueMessage::RemoveUserProfile(message) => message.clone(),-- SearchQueueMessage::UpdateEntityName(message)- | SearchQueueMessage::RemoveEntityName(message) => message.entity_id.to_string(),}}}@@ -140,9 +131,6 @@ impl SearchQueueMessage {SearchQueueMessage::RemoveChannelMessage(_) => Operation::Remove,// UsersSearchQueueMessage::RemoveUserProfile(_) => Operation::Remove,- // Entity Name- SearchQueueMessage::UpdateEntityName(_) => Operation::UpdateMetadata,- SearchQueueMessage::RemoveEntityName(_) => Operation::Remove,}}}diff --git a/rust/cloud-storage/sqs_client/src/search/name.rs b/rust/cloud-storage/sqs_client/src/search/name.rsdeleted file mode 100644index d60b65a7b3..0000000000--- a/rust/cloud-storage/sqs_client/src/search/name.rs+++ /dev/null@@ -1,10 +0,0 @@-use models_opensearch::SearchEntityType;--/// Update entity name message-/// Sent to SPS via a queue for processing to update the names index with the new name-/// of the entity-#[derive(serde::Serialize, serde::Deserialize, PartialEq, Eq, Debug)]-pub struct EntityName {- pub entity_id: uuid::Uuid,- pub entity_type: SearchEntityType,-}