Skip to main content

SearchQuery

Struct SearchQuery 

Source
pub struct SearchQuery { /* private fields */ }
Expand description

A vector similarity search query.

Implementations§

Source§

impl SearchQuery

Source

pub unsafe fn as_raw(&self) -> *mut zvec_vector_query_t

Returns the raw FFI handle.

§Safety

The caller must not use the handle after the SearchQuery is dropped.

Source

pub unsafe fn from_raw(handle: *mut zvec_vector_query_t) -> Self

Creates a SearchQuery from a raw FFI handle.

§Safety

The caller must ensure the handle is valid and was created by the zvec C API. The SearchQuery takes ownership and will call zvec_vector_query_destroy on drop.

Source

pub fn new(field_name: &str, vector: &[f32], topk: i32) -> Result<Self>

Creates a new vector query with the given field name, query vector, and topk.

Source

pub fn fts(field_name: &str, fts: &Fts, topk: i32) -> Result<Self>

Creates a pure full-text (keyword-only) search query with no dense vector.

SearchQuery::new and SearchQueryBuilder::build both require a query vector, so an FTS clause can only ever be layered on top of a dense vector (hybrid search). This constructor reaches the C API’s vector-less FTS path: once an FTS payload is attached, the underlying zvec_vector_query does not require a query vector, enabling keyword-only retrieval.

field_name must be the FTS-indexed field.

Source

pub fn builder() -> SearchQueryBuilder

Returns a builder for constructing a search query.

Source

pub fn set_filter(&mut self, filter: &str) -> Result<()>

Sets the filter expression.

Source

pub fn set_include_vector(&mut self, include: bool) -> Result<()>

Sets whether to include vector data in results.

Source

pub fn set_include_doc_id(&mut self, include: bool) -> Result<()>

Sets whether to include doc ID in results.

Source

pub fn set_output_fields(&mut self, fields: &[&str]) -> Result<()>

Sets the output fields to include in results.

Source

pub fn set_hnsw_params(&mut self, params: HnswQueryParams) -> Result<()>

Sets HNSW query parameters (takes ownership on success).

Source

pub fn set_ivf_params(&mut self, params: IvfQueryParams) -> Result<()>

Sets IVF query parameters (takes ownership on success).

Source

pub fn set_ivf_rabitq_params( &mut self, params: IvfRabitqQueryParams, ) -> Result<()>

Sets IVF RaBitQ query parameters (takes ownership on success).

Source

pub fn set_flat_params(&mut self, params: FlatQueryParams) -> Result<()>

Sets Flat query parameters (takes ownership on success).

Source

pub fn set_diskann_params(&mut self, params: DiskannQueryParams) -> Result<()>

Sets DiskANN query parameters (takes ownership on success).

Source

pub fn set_fts_params(&mut self, params: FtsQueryParams) -> Result<()>

Sets FTS query parameters (takes ownership on success).

Source

pub fn set_fts(&mut self, fts: &Fts) -> Result<()>

Sets FTS payload (payload is copied, caller retains ownership).

Trait Implementations§

Source§

impl Drop for SearchQuery

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.