pub struct VectorConfig {
pub dimensions: u32,
pub index_type: VectorIndexType,
pub distance_metric: DistanceMetric,
}Expand description
Configuration for a vector field (pgvector).
This represents the configuration for a vector embedding field, including dimensions, index type, and distance metric.
§Example
use fraiseql_core::schema::{VectorConfig, VectorIndexType, DistanceMetric};
let config = VectorConfig {
dimensions: 1536,
index_type: VectorIndexType::Hnsw,
distance_metric: DistanceMetric::Cosine,
};Fields§
§dimensions: u32Number of dimensions in the vector (e.g., 1536 for OpenAI embeddings).
index_type: VectorIndexTypeType of index to use for similarity search.
distance_metric: DistanceMetricDistance metric for similarity calculations.
Implementations§
Source§impl VectorConfig
impl VectorConfig
Sourcepub fn new(dimensions: u32) -> Self
pub fn new(dimensions: u32) -> Self
Create a new vector config with default index and distance metric.
Sourcepub fn openai() -> Self
pub fn openai() -> Self
Create a vector config for OpenAI embeddings (1536 dimensions, cosine).
Sourcepub fn openai_small() -> Self
pub fn openai_small() -> Self
Create a vector config for OpenAI small embeddings (512 dimensions, cosine).
Sourcepub fn with_index(self, index_type: VectorIndexType) -> Self
pub fn with_index(self, index_type: VectorIndexType) -> Self
Set the index type.
Sourcepub fn with_distance(self, distance_metric: DistanceMetric) -> Self
pub fn with_distance(self, distance_metric: DistanceMetric) -> Self
Set the distance metric.
Trait Implementations§
Source§impl Clone for VectorConfig
impl Clone for VectorConfig
Source§fn clone(&self) -> VectorConfig
fn clone(&self) -> VectorConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VectorConfig
impl Debug for VectorConfig
Source§impl Default for VectorConfig
impl Default for VectorConfig
Source§impl<'de> Deserialize<'de> for VectorConfig
impl<'de> Deserialize<'de> for VectorConfig
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for VectorConfig
impl PartialEq for VectorConfig
Source§impl Serialize for VectorConfig
impl Serialize for VectorConfig
impl StructuralPartialEq for VectorConfig
Auto Trait Implementations§
impl Freeze for VectorConfig
impl RefUnwindSafe for VectorConfig
impl Send for VectorConfig
impl Sync for VectorConfig
impl Unpin for VectorConfig
impl UnsafeUnpin for VectorConfig
impl UnwindSafe for VectorConfig
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
Mutably borrows from an owned value. Read more