feat(elasticsearch): add mapping, settings, stats and clear actions

This commit is contained in:
onenewcode authored and GitHub committed 2026-08-31 22:31:35 +08:00
1 parent a84cb637ba
commit 8f3134dce8
32 files changed
+1262 -3

No files matched your search

+8
View File
@@ -818,6 +818,14 @@ async fn main() {
"/document-store/elasticsearch-count-documents",
post(routes::document_store::elasticsearch_count_documents),
)
.route(
"/document-store/elasticsearch/index-metadata",
post(routes::document_store::elasticsearch_get_index_metadata),
)
.route(
"/document-store/elasticsearch/documents/delete-all",
post(routes::document_store::elasticsearch_delete_all_documents),
)
.route("/document-store/list-gridfs-buckets", post(routes::document_store::list_gridfs_buckets))
.route("/document-store/create-gridfs-bucket", post(routes::document_store::create_gridfs_bucket))
.route("/document-store/delete-gridfs-bucket", post(routes::document_store::delete_gridfs_bucket))
@@ -98,6 +98,21 @@ pub struct ElasticsearchCountDocumentsRequest {
pub execution_id: Option<String>,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ElasticsearchIndexRequest {
pub connection_id: String,
pub index: String,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ElasticsearchIndexMetadataRequest {
pub connection_id: String,
pub index: String,
pub kind: dbx_core::document_ops::ElasticsearchIndexMetadataKind,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentInsertRequest {
@@ -385,6 +400,33 @@ pub async fn elasticsearch_count_documents(
Ok(Json(result))
}
pub async fn elasticsearch_get_index_metadata(
State(state): State<Arc<WebState>>,
Json(req): Json<ElasticsearchIndexMetadataRequest>,
) -> Result<Json<serde_json::Value>, AppError> {
let result = dbx_core::document_ops::elasticsearch_get_index_metadata_core(
&state.app,
&req.connection_id,
&req.index,
req.kind,
)
.await
.map_err(AppError::from)?;
Ok(Json(result))
}
pub async fn elasticsearch_delete_all_documents(
State(state): State<Arc<WebState>>,
Json(req): Json<ElasticsearchIndexRequest>,
) -> Result<Json<dbx_core::db::elasticsearch_driver::ElasticsearchDeleteByQueryResult>, AppError> {
ensure_writable(&state.app, &req.connection_id, "Delete all documents").await?;
let result =
dbx_core::document_ops::elasticsearch_delete_all_documents_core(&state.app, &req.connection_id, &req.index)
.await
.map_err(AppError::from)?;
Ok(Json(result))
}
pub async fn insert_document(
State(state): State<Arc<WebState>>,
Json(req): Json<DocumentInsertRequest>,