pub struct VectorIndex {
pub name: String,
pub table: String,
pub column: String,
pub metric: DistanceMetric,
pub index_type: IndexType,
pub concurrent: bool,
pub if_not_exists: bool,
}Expand description
A vector index definition.
§Examples
use prax_pgvector::index::{VectorIndex, HnswConfig};
use prax_pgvector::DistanceMetric;
// Create an HNSW index
let index = VectorIndex::hnsw("idx_embedding", "documents", "embedding")
.metric(DistanceMetric::Cosine)
.config(HnswConfig::high_recall())
.build()
.unwrap();
let sql = index.to_create_sql();
assert!(sql.contains("USING hnsw"));
assert!(sql.contains("vector_cosine_ops"));Fields§
§name: StringIndex name.
table: StringTable name.
column: StringColumn name.
metric: DistanceMetricDistance metric.
index_type: IndexTypeIndex type and configuration.
concurrent: boolWhether to create concurrently (non-blocking).
if_not_exists: boolWhether to add IF NOT EXISTS clause.
Implementations§
Source§impl VectorIndex
impl VectorIndex
Sourcepub fn hnsw(
name: impl Into<String>,
table: impl Into<String>,
column: impl Into<String>,
) -> VectorIndexBuilder
pub fn hnsw( name: impl Into<String>, table: impl Into<String>, column: impl Into<String>, ) -> VectorIndexBuilder
Start building an HNSW index.
Sourcepub fn ivfflat(
name: impl Into<String>,
table: impl Into<String>,
column: impl Into<String>,
) -> VectorIndexBuilder
pub fn ivfflat( name: impl Into<String>, table: impl Into<String>, column: impl Into<String>, ) -> VectorIndexBuilder
Start building an IVFFlat index.
Sourcepub fn to_create_sql(&self) -> String
pub fn to_create_sql(&self) -> String
Generate the CREATE INDEX SQL statement.
Sourcepub fn to_drop_sql(&self) -> String
pub fn to_drop_sql(&self) -> String
Generate the DROP INDEX SQL statement.
Sourcepub fn to_exists_sql(&self) -> String
pub fn to_exists_sql(&self) -> String
Generate SQL to check if this index exists.
Sourcepub fn to_size_sql(&self) -> String
pub fn to_size_sql(&self) -> String
Generate SQL to get the index size.
Trait Implementations§
Source§impl Clone for VectorIndex
impl Clone for VectorIndex
Source§fn clone(&self) -> VectorIndex
fn clone(&self) -> VectorIndex
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 VectorIndex
impl Debug for VectorIndex
Source§impl<'de> Deserialize<'de> for VectorIndex
impl<'de> Deserialize<'de> for VectorIndex
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 VectorIndex
impl PartialEq for VectorIndex
Source§impl Serialize for VectorIndex
impl Serialize for VectorIndex
impl Eq for VectorIndex
impl StructuralPartialEq for VectorIndex
Auto Trait Implementations§
impl Freeze for VectorIndex
impl RefUnwindSafe for VectorIndex
impl Send for VectorIndex
impl Sync for VectorIndex
impl Unpin for VectorIndex
impl UnsafeUnpin for VectorIndex
impl UnwindSafe for VectorIndex
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