diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 8b210bf91b..c1a3f18d62 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -3122,6 +3122,7 @@ export default {
requestEditor: "Vector request editor",
operationSuccess: "Operation completed. The collection preview has been refreshed.",
vectorLabel: "Vector",
+ vectorDimensionRequired: "Collection dimensions are not available yet. Enter a vector matching the collection dimension.",
},
history: {
title: "History",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index e31cf1c110..d3244a528b 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -2979,6 +2979,7 @@ export default withEnglishFallback({
requestEditor: "Editor de solicitudes vectoriales",
operationSuccess: "Operación completada. La vista previa de la colección se ha actualizado.",
vectorLabel: "Vector",
+ vectorDimensionRequired: "La dimensión de la colección aún no está disponible. Introduce un vector con la dimensión correcta.",
},
history: {
title: "Historial",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 5222135f27..bc7b448e76 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -2977,6 +2977,7 @@ export default withEnglishFallback({
requestEditor: "Editor richieste vettoriali",
operationSuccess: "Operazione completata. L'anteprima della collezione e stata aggiornata.",
vectorLabel: "Vettore",
+ vectorDimensionRequired: "La dimensione della collezione non è ancora disponibile. Inserisci un vettore con la dimensione corretta.",
},
history: {
title: "Cronologia",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index 49a461c478..9d5e4e8d5f 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -2978,6 +2978,7 @@ export default withEnglishFallback({
requestEditor: "ベクターリクエストエディタ",
operationSuccess: "操作が完了しました。コレクションプレビューが更新されました。",
vectorLabel: "ベクトル",
+ vectorDimensionRequired: "コレクションの次元をまだ取得できません。次元が一致するベクトルを入力してください。",
},
history: {
title: "履歴",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index 14e81776ae..ad53d24f0b 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -2979,6 +2979,7 @@ export default withEnglishFallback({
requestEditor: "Editor de requisição de vetor",
operationSuccess: "Operação concluída. A pré-visualização da coleção foi atualizada.",
vectorLabel: "Vetor",
+ vectorDimensionRequired: "A dimensão da coleção ainda não está disponível. Insira um vetor com a dimensão correta.",
},
history: {
title: "Histórico",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index c60af93a3a..9e70f69332 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -3122,6 +3122,7 @@ export default withEnglishFallback({
requestEditor: "向量请求编辑器",
operationSuccess: "操作已完成,集合预览已刷新。",
vectorLabel: "向量",
+ vectorDimensionRequired: "暂未获取到集合维度,请先输入与集合维度一致的向量。",
},
history: {
title: "历史",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 84c1be2321..c9a1a3766d 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -2650,6 +2650,7 @@ export default withEnglishFallback({
requestEditor: "向量請求編輯器",
operationSuccess: "操作已完成,集合預覽已重新整理。",
vectorLabel: "向量",
+ vectorDimensionRequired: "尚未取得集合維度,請先輸入與集合維度一致的向量。",
},
history: {
title: "歷史",
diff --git a/crates/dbx-core/src/db/vector_driver.rs b/crates/dbx-core/src/db/vector_driver.rs
index 5a8aa05a71..e3411fafd2 100644
--- a/crates/dbx-core/src/db/vector_driver.rs
+++ b/crates/dbx-core/src/db/vector_driver.rs
@@ -302,20 +302,27 @@ pub async fn get_collection_detail(
match client.kind {
VectorDbKind::Qdrant => get_qdrant_collection_detail(client, collection).await,
VectorDbKind::Milvus => get_milvus_collection_detail(client, database, collection).await,
- VectorDbKind::Weaviate => {
- // Weaviate REST API does not expose vector dimension
- Ok(CollectionInfo {
- name: collection.to_string(),
- id: collection.to_string(),
- dimension: None,
- kind: None,
- bucket_name: None,
- })
- }
+ VectorDbKind::Weaviate => get_weaviate_collection_detail(client, collection).await,
VectorDbKind::ChromaDb => get_chroma_collection_detail(client, collection).await,
}
}
+async fn get_weaviate_collection_detail(client: &VectorClient, collection: &str) -> Result {
+ let query = format!("{{ Get {{ {collection}(limit: 1) {{ _additional {{ vector }} }} }} }}");
+ let dimension =
+ match send_json(client.post("/v1/graphql").json(&serde_json::json!({ "query": query })), "Weaviate").await {
+ Ok(body) => weaviate_vector_dimension_from_graphql(&body, collection),
+ Err(_) => None,
+ };
+ Ok(CollectionInfo {
+ name: collection.to_string(),
+ id: collection.to_string(),
+ dimension,
+ kind: None,
+ bucket_name: None,
+ })
+}
+
async fn get_qdrant_collection_detail(client: &VectorClient, collection: &str) -> Result {
let body = send_json(client.get(&format!("/collections/{}", path_segment(collection))), "Qdrant").await?;
let dim = body
@@ -468,6 +475,18 @@ fn weaviate_graphql_to_rows(body: &Value) -> Option> {
)
}
+fn weaviate_vector_dimension_from_graphql(body: &Value, collection: &str) -> Option {
+ let vector = body
+ .get("data")?
+ .get("Get")?
+ .get(collection)?
+ .as_array()?
+ .first()?
+ .pointer("/_additional/vector")?
+ .as_array()?;
+ u32::try_from(vector.len()).ok().filter(|dimension| *dimension > 0)
+}
+
fn weaviate_collection_names_from_schema(body: &Value) -> Vec {
body.get("classes")
.and_then(Value::as_array)
@@ -782,7 +801,8 @@ fn format_reqwest_error(err: &reqwest::Error) -> String {
mod tests {
use super::{
chroma_get_response_to_rows, starts_with_http_method, values_to_query_result, vector_auth,
- weaviate_collection_names_from_schema, CollectionInfo, VectorAuth, VectorDbKind,
+ weaviate_collection_names_from_schema, weaviate_vector_dimension_from_graphql, CollectionInfo, VectorAuth,
+ VectorDbKind,
};
use serde_json::json;
use std::time::Instant;
@@ -814,6 +834,25 @@ mod tests {
assert_eq!(names, vec!["Article".to_string(), "Product".to_string()]);
}
+ #[test]
+ fn extracts_weaviate_vector_dimension_from_first_object() {
+ let vector = vec![0.0; 1024];
+ let body = json!({
+ "data": {
+ "Get": {
+ "Article": [{ "_additional": { "vector": vector } }]
+ }
+ }
+ });
+ assert_eq!(weaviate_vector_dimension_from_graphql(&body, "Article"), Some(1024));
+ }
+
+ #[test]
+ fn leaves_weaviate_dimension_unknown_for_empty_collections() {
+ let body = json!({ "data": { "Get": { "Article": [] } } });
+ assert_eq!(weaviate_vector_dimension_from_graphql(&body, "Article"), None);
+ }
+
#[test]
fn flattens_weaviate_properties_columns() {
let result = values_to_query_result(