From af4ac9574abd59ae0a4f8b64cdab40c25ed6e10c Mon Sep 17 00:00:00 2001 From: Javier Torres Date: Mon, 10 Jun 2024 11:12:48 +0200 Subject: [PATCH] Fallback to unaligned vectors if dimension not specified --- nucliadb_vectors/src/config.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nucliadb_vectors/src/config.rs b/nucliadb_vectors/src/config.rs index 7a767a07b4..c31b693a59 100644 --- a/nucliadb_vectors/src/config.rs +++ b/nucliadb_vectors/src/config.rs @@ -21,6 +21,7 @@ use std::mem::size_of; use nucliadb_core::protos::VectorIndexConfig; use nucliadb_core::protos::{VectorSimilarity, VectorType as ProtoVectorType}; +use nucliadb_core::tracing::warn; use serde::{Deserialize, Serialize}; use crate::vector_types::*; @@ -121,6 +122,10 @@ impl TryFrom for VectorConfig { fn try_from(proto: VectorIndexConfig) -> Result { let vector_type = match (proto.vector_type(), proto.vector_dimension) { + (ProtoVectorType::DenseF32, Some(0)) => { + warn!("Trying to create a shard with dimension = 0. Falling back to unaligned vectors"); + VectorType::DenseF32Unaligned + } (ProtoVectorType::DenseF32, Some(dim)) => VectorType::DenseF32 { dimension: dim as usize, },