pub struct DenseVectorConfig {
pub dim: usize,
pub index_type: VectorIndexType,
pub quantization: DenseVectorQuantization,
pub num_clusters: Option<usize>,
pub nprobe: usize,
pub build_threshold: Option<usize>,
pub unit_norm: bool,
}Expand description
Configuration for dense vector fields using Flat, RaBitQ, IVF-RaBitQ, or ScaNN
Indexes operate in two states:
- Flat (accumulating): Brute-force search over raw vectors. Used when vector count
is below
build_thresholdor beforebuild_indexis called. - Built (ANN): Fast approximate nearest neighbor search using trained structures. Centroids and codebooks are trained from data and stored within the segment.
Fields§
§dim: usizeDimensionality of vectors
index_type: VectorIndexTypeTarget vector index algorithm (Flat, RaBitQ, IVF-RaBitQ, or ScaNN) 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 clusters for IVF-RaBitQ and ScaNN (default: sqrt(n) capped at 4096) If None, automatically determined based on dataset size.
nprobe: usizeNumber of clusters to probe during search (default: 32)
build_threshold: Option<usize>Minimum number of vectors required before building ANN index. Below this threshold, brute-force (Flat) search is used. Default: 1000 for RaBitQ, 10000 for IVF-RaBitQ/ScaNN.
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).
Implementations§
Source§impl DenseVectorConfig
impl DenseVectorConfig
pub fn new(dim: usize) -> Self
Sourcepub fn with_ivf(dim: usize, num_clusters: Option<usize>, nprobe: usize) -> Self
pub fn with_ivf(dim: usize, num_clusters: Option<usize>, nprobe: usize) -> Self
Create IVF-RaBitQ configuration
Sourcepub fn with_scann(
dim: usize,
num_clusters: Option<usize>,
nprobe: usize,
) -> Self
pub fn with_scann( dim: usize, num_clusters: Option<usize>, nprobe: usize, ) -> Self
Create ScaNN configuration
Sourcepub fn with_quantization(self, quantization: DenseVectorQuantization) -> Self
pub fn with_quantization(self, quantization: DenseVectorQuantization) -> Self
Set storage quantization
Sourcepub fn with_build_threshold(self, threshold: usize) -> Self
pub fn with_build_threshold(self, threshold: usize) -> Self
Set build threshold for auto-building ANN index
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 uses_scann(&self) -> bool
pub fn uses_scann(&self) -> bool
Check if this config uses ScaNN
Sourcepub fn default_build_threshold(&self) -> usize
pub fn default_build_threshold(&self) -> usize
Get the default build threshold for this index type
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 · 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<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.