我尝试使用elasticsearch8.4.0-alpha.1库在Rust编程语言中实现机器学习API,现在卡住了。我想使用已经在Elasticsearch中导入的ML模型,它将文本转换为矢量。请帮帮我
pub async fn vector_search(data: web::Json<Value>) -> Result<HttpResponse, CustomError> {
let client = get_client().unwrap();
let infer_response = client
.ml().get_trained_models(elasticsearch::ml::Ml::get_trained_models())
.send()
.await
.unwrap();
let response_id_body = infer_response.json::<Value>().await.unwrap();
Ok(HttpResponse::Ok().json(json!(response_id_body)))
}
字符串
1条答案
按热度按时间jrcvhitl1#
要在Elasticsearch中使用预训练的ML模型将文本转换为矢量,以下步骤对我来说很有效:
字符串
型
型
型
将“your_model_id”替换为您想要使用的训练模型的ID。将“your_text_field”替换为Elasticsearch索引中包含文本数据的字段的名称。将“your_text_data”替换为要转换为矢量的实际文本。