pub struct HybridSearchBuilder { /* private fields */ }Expand description
Builder for hybrid search queries that combine vector similarity with full-text search.
This generates queries that use both pgvector distance operators and PostgreSQL tsvector/tsquery for combined similarity scoring.
§Examples
use prax_pgvector::query::HybridSearchBuilder;
use prax_pgvector::{Embedding, DistanceMetric};
let query = HybridSearchBuilder::new("documents")
.vector_column("embedding")
.text_column("content")
.query_vector(Embedding::new(vec![0.1, 0.2, 0.3]))
.query_text("machine learning")
.metric(DistanceMetric::Cosine)
.vector_weight(0.7)
.text_weight(0.3)
.limit(10)
.build();
let sql = query.to_sql();Implementations§
Source§impl HybridSearchBuilder
impl HybridSearchBuilder
Sourcepub fn vector_column(self, column: impl Into<String>) -> Self
pub fn vector_column(self, column: impl Into<String>) -> Self
Set the vector column name.
Sourcepub fn text_column(self, column: impl Into<String>) -> Self
pub fn text_column(self, column: impl Into<String>) -> Self
Set the text column name.
Sourcepub fn query_vector(self, embedding: Embedding) -> Self
pub fn query_vector(self, embedding: Embedding) -> Self
Set the query vector.
Sourcepub fn query_text(self, text: impl Into<String>) -> Self
pub fn query_text(self, text: impl Into<String>) -> Self
Set the text query.
Sourcepub fn metric(self, metric: DistanceMetric) -> Self
pub fn metric(self, metric: DistanceMetric) -> Self
Set the vector distance metric.
Sourcepub fn vector_weight(self, weight: f64) -> Self
pub fn vector_weight(self, weight: f64) -> Self
Set the weight for the vector similarity component (0.0 to 1.0).
Sourcepub fn text_weight(self, weight: f64) -> Self
pub fn text_weight(self, weight: f64) -> Self
Set the weight for the text relevance component (0.0 to 1.0).
Sourcepub fn where_clause(self, condition: impl Into<String>) -> Self
pub fn where_clause(self, condition: impl Into<String>) -> Self
Add a WHERE condition.
Sourcepub fn build(self) -> HybridSearchQuery
pub fn build(self) -> HybridSearchQuery
Build the hybrid search query.
Auto Trait Implementations§
impl Freeze for HybridSearchBuilder
impl RefUnwindSafe for HybridSearchBuilder
impl Send for HybridSearchBuilder
impl Sync for HybridSearchBuilder
impl Unpin for HybridSearchBuilder
impl UnsafeUnpin for HybridSearchBuilder
impl UnwindSafe for HybridSearchBuilder
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