diff --git a/_elasticsearch/index_definitions/model_weights_v1.json b/_elasticsearch/index_definitions/model_weights_v1.json index 1028619e1d..f23a37aa95 100644 --- a/_elasticsearch/index_definitions/model_weights_v1.json +++ b/_elasticsearch/index_definitions/model_weights_v1.json @@ -13,6 +13,7 @@ "weights_category" : { "type" : "keyword" }, "title" : { "type" : "search_as_you_type" }, + "title_as_keyword" : { "type" : "keyword" }, "maybe_cover_image_media_file_token" : { "type" : "keyword" }, "maybe_cover_image_public_bucket_hash" : { "type" : "keyword" }, diff --git a/crates/cli/production/elasticsearch-cli/src/plans/create_all_model_weight_documents.rs b/crates/cli/production/elasticsearch-cli/src/plans/create_all_model_weight_documents.rs index 5122078b5e..fbe3a10418 100644 --- a/crates/cli/production/elasticsearch-cli/src/plans/create_all_model_weight_documents.rs +++ b/crates/cli/production/elasticsearch-cli/src/plans/create_all_model_weight_documents.rs @@ -13,7 +13,11 @@ use errors::AnyhowResult; use mysql_queries::queries::model_weights::list::list_model_weights_for_elastic_search_backfill_using_cursor::{list_model_weights_for_elastic_search_backfill_using_cursor, ModelWeightForElasticsearchRecord}; use storyteller_root::get_storyteller_rust_root; -pub async fn create_all_model_weight_documents(mysql: &Pool, elasticsearch: &Elasticsearch) -> AnyhowResult<()> { +pub async fn create_all_model_weight_documents( + mysql: &Pool, + elasticsearch: &Elasticsearch +) -> AnyhowResult<()> { + info!("Create all model weight documents."); // TODO(bt, 2024-01-10): expose this as a CLI flag @@ -63,7 +67,8 @@ async fn create_document_from_record(elasticsearch: &Elasticsearch, record: Mode weights_type: record.weights_type, weights_category: record.weights_category, - title: record.title, + title: record.title.clone(), + title_as_keyword: record.title, maybe_cover_image_media_file_token: record.maybe_cover_image_media_file_token, maybe_cover_image_public_bucket_hash: record.maybe_cover_image_public_bucket_hash, diff --git a/crates/lib/elasticsearch_schema/src/documents/model_weight_document.rs b/crates/lib/elasticsearch_schema/src/documents/model_weight_document.rs index ad5be53cce..1e2bd588d6 100644 --- a/crates/lib/elasticsearch_schema/src/documents/model_weight_document.rs +++ b/crates/lib/elasticsearch_schema/src/documents/model_weight_document.rs @@ -30,6 +30,10 @@ pub struct ModelWeightDocument { pub title: String, + // NB: Not all datatypes are supported in the SQL DSL, so we have a copy of the title: + // https://opensearch.org/docs/latest/search-plugins/sql/datatypes/ + pub title_as_keyword: String, + // *** NB: Never put the bucket path to the model in Elasticsearch ! *** pub maybe_cover_image_media_file_token: Option,