25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(weaviate): avoid mismatched search vector dimensions
t8y204e26670954b
diff --git a/apps/desktop/src/components/vector/VectorBrowser.vue b/apps/desktop/src/components/vector/VectorBrowser.vueindex c4c897ba18..2378593df0 100644--- a/apps/desktop/src/components/vector/VectorBrowser.vue+++ b/apps/desktop/src/components/vector/VectorBrowser.vue@@ -75,6 +75,8 @@ const operationIcon = computed(() => {return Play;}});+const needsExplicitSearchVector = computed(() => operationMode.value === "search" && props.databaseType === "weaviate" && props.dimension == null && parseVector(searchVector.value) == null);+const executeDisabled = computed(() => loading.value || !requestText.value.trim() || needsExplicitSearchVector.value);watch(() => [props.databaseType, props.database, props.collection] as const,@@ -87,7 +89,7 @@ watch();watch(- () => [operationMode.value, searchVector.value, searchTopK.value] as const,+ () => [operationMode.value, searchVector.value, searchTopK.value, props.dimension] as const,() => {if (operationMode.value === "search") {requestText.value = defaultRequestText(props.databaseType, props.database, props.collection, operationMode.value);@@ -216,11 +218,18 @@ function defaultRequestText(databaseType: DatabaseType | undefined, database: streturn `POST /collections/${collectionPath}/points/scroll\n${JSON.stringify({ limit: 100, with_payload: true, with_vector: false }, null, 2)}`;}-function tryParseVector(input: string): number[] {+function parseVector(input: string): number[] | undefined {try {const parsed = JSON.parse(input);- if (Array.isArray(parsed)) return parsed;+ if (Array.isArray(parsed) && parsed.length > 0) return parsed;} catch {}+ return undefined;+}++function tryParseVector(input: string): number[] {+ const parsed = parseVector(input);+ if (parsed) return parsed;+ if (props.databaseType === "weaviate" && props.dimension == null) return [];return sampleVector();}@@ -343,7 +352,7 @@ function setOperationMode(mode: VectorOperationMode) {<RefreshCcw class="h-3.5 w-3.5" />{{ t("vector.refresh") }}</Button>- <Button size="sm" class="h-7 gap-1.5 px-2" :disabled="loading || !requestText.trim()" @click="runRequest">+ <Button size="sm" class="h-7 gap-1.5 px-2" :disabled="executeDisabled" @click="runRequest"><component :is="operationIcon" class="h-3.5 w-3.5" />{{ executeLabel }}</Button>@@ -359,6 +368,7 @@ function setOperationMode(mode: VectorOperationMode) {<span>topK</span><input v-model.number="searchTopK" type="number" min="1" max="1000" class="h-7 w-16 rounded border bg-muted/30 px-2 text-xs outline-none focus:border-primary" /></div>+ <span v-if="needsExplicitSearchVector" class="text-xs text-amber-600 dark:text-amber-400">{{ t("vector.vectorDimensionRequired") }}</span></div><div class="grid min-h-0 flex-1 grid-rows-[minmax(9rem,15rem)_1fr]"><div class="min-h-0 border-b">diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.rsindex 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<CollectionInfo, String> {+ 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<CollectionInfo, String> {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<Vec<Value>> {)}+fn weaviate_vector_dimension_from_graphql(body: &Value, collection: &str) -> Option<u32> {+ 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<String> {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(