pub struct DenseVectorConfig {
pub dim: usize,
pub index_type: VectorIndexType,
pub quantization: DenseVectorQuantization,
pub num_clusters: Option<usize>,
pub ivf_routing: IvfRoutingMode,
pub nprobe: usize,
pub unit_norm: bool,
pub soar: Option<SoarConfig>,
}Expand description
Configuration for dense vector fields using exact Flat accumulation or the single production IVF-PQ ANN format.
Indexes operate in two states:
- Flat (accumulating): Brute-force search over raw vectors before
build_vector_indexis called. - Built (ANN): Fast approximate nearest neighbor search using trained structures. Centroids and codebooks are trained from index-wide data and shared by every segment; segment payloads contain only assignments and PQ codes.
Fields§
§dim: usizeDimensionality of vectors
index_type: VectorIndexTypeTarget vector index algorithm (Flat or IVF-PQ). When in accumulating state, search uses brute-force regardless of this setting.
quantization: DenseVectorQuantizationStorage quantization for vector elements (f32, f16, uint8)
num_clusters: Option<usize>Number of IVF leaf clusters. If omitted, a billion-scale cost model and the available training sample determine the value. If None, automatically determined based on dataset size.
ivf_routing: IvfRoutingModeCoarse-codebook routing strategy. This setting is metric agnostic and is applied to every IVF-backed dense index.
nprobe: usizeNumber of leaf clusters to probe during search (default: 64)
unit_norm: boolWhether stored vectors are pre-normalized to unit L2 norm. When true, scoring skips per-vector norm computation (cosine = dot / ||q||), reducing compute by ~40%. Common for embedding models (e.g. OpenAI, Cohere). Default: true (most embedding models produce L2-normalized vectors).
soar: Option<SoarConfig>SOAR spilled cluster assignments for IVF-PQ. Assigns vectors to a secondary cluster with an orthogonality-amplified residual, improving recall at the same nprobe for ~1.2-2x assignment storage. Default: None (disabled). Ignored while a field remains flat.
Implementations§
Source§impl DenseVectorConfig
impl DenseVectorConfig
pub fn new(dim: usize) -> Self
Sourcepub fn with_ivf_pq(
dim: usize,
num_clusters: Option<usize>,
nprobe: usize,
) -> Self
pub fn with_ivf_pq( dim: usize, num_clusters: Option<usize>, nprobe: usize, ) -> Self
Create IVF-PQ configuration.
Sourcepub fn with_quantization(self, quantization: DenseVectorQuantization) -> Self
pub fn with_quantization(self, quantization: DenseVectorQuantization) -> Self
Set storage quantization
Sourcepub fn with_unit_norm(self) -> Self
pub fn with_unit_norm(self) -> Self
Mark vectors as pre-normalized to unit L2 norm
Sourcepub fn with_num_clusters(self, num_clusters: usize) -> Self
pub fn with_num_clusters(self, num_clusters: usize) -> Self
Set number of IVF clusters
Sourcepub fn with_ivf_routing(self, routing: IvfRoutingMode) -> Self
pub fn with_ivf_routing(self, routing: IvfRoutingMode) -> Self
Set flat, two-level, or HNSW IVF centroid routing explicitly.
Sourcepub fn with_soar(self, soar: SoarConfig) -> Self
pub fn with_soar(self, soar: SoarConfig) -> Self
Enable SOAR spilled secondary cluster assignments (IVF-based indexes only)
Sourcepub fn optimal_num_clusters(&self, num_vectors: usize) -> usize
pub fn optimal_num_clusters(&self, num_vectors: usize) -> usize
Calculate optimal number of clusters for given vector count
Trait Implementations§
Source§impl Clone for DenseVectorConfig
impl Clone for DenseVectorConfig
Source§fn clone(&self) -> DenseVectorConfig
fn clone(&self) -> DenseVectorConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DenseVectorConfig
impl Debug for DenseVectorConfig
Source§impl<'de> Deserialize<'de> for DenseVectorConfig
impl<'de> Deserialize<'de> for DenseVectorConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for DenseVectorConfig
impl RefUnwindSafe for DenseVectorConfig
impl Send for DenseVectorConfig
impl Sync for DenseVectorConfig
impl Unpin for DenseVectorConfig
impl UnsafeUnpin for DenseVectorConfig
impl UnwindSafe for DenseVectorConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<E> ResultError for E
impl<T> ResultType for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.