pub struct SearchIndex {
pub name: String,
pub prefix: String,
pub fields: Vec<SearchField>,
}Expand description
Search index definition
Fields§
§name: StringIndex name (will be prefixed with “idx:”)
prefix: StringKey prefix this index covers (e.g., “crdt:users:”)
fields: Vec<SearchField>Field definitions for the index
Implementations§
Source§impl SearchIndex
impl SearchIndex
Sourcepub fn new(name: impl Into<String>, prefix: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, prefix: impl Into<String>) -> Self
Create a new search index definition
Sourcepub fn text_at(
self,
name: impl Into<String>,
json_path: impl Into<String>,
) -> Self
pub fn text_at( self, name: impl Into<String>, json_path: impl Into<String>, ) -> Self
Add a text field with custom JSON path
Sourcepub fn text_sortable(self, name: impl Into<String>) -> Self
pub fn text_sortable(self, name: impl Into<String>) -> Self
Add a sortable text field
Sourcepub fn text_sortable_at(
self,
name: impl Into<String>,
json_path: impl Into<String>,
) -> Self
pub fn text_sortable_at( self, name: impl Into<String>, json_path: impl Into<String>, ) -> Self
Add a sortable text field with custom JSON path
Sourcepub fn numeric_at(
self,
name: impl Into<String>,
json_path: impl Into<String>,
) -> Self
pub fn numeric_at( self, name: impl Into<String>, json_path: impl Into<String>, ) -> Self
Add a numeric field with custom JSON path
Sourcepub fn numeric_sortable(self, name: impl Into<String>) -> Self
pub fn numeric_sortable(self, name: impl Into<String>) -> Self
Add a sortable numeric field
Sourcepub fn numeric_sortable_at(
self,
name: impl Into<String>,
json_path: impl Into<String>,
) -> Self
pub fn numeric_sortable_at( self, name: impl Into<String>, json_path: impl Into<String>, ) -> Self
Add a sortable numeric field with custom JSON path
Sourcepub fn tag_at(
self,
name: impl Into<String>,
json_path: impl Into<String>,
) -> Self
pub fn tag_at( self, name: impl Into<String>, json_path: impl Into<String>, ) -> Self
Add a tag field with custom JSON path
Sourcepub fn geo_at(
self,
name: impl Into<String>,
json_path: impl Into<String>,
) -> Self
pub fn geo_at( self, name: impl Into<String>, json_path: impl Into<String>, ) -> Self
Add a geo field with custom JSON path
Sourcepub fn vector_hnsw(
self,
name: impl Into<String>,
dim: usize,
metric: DistanceMetric,
) -> Self
pub fn vector_hnsw( self, name: impl Into<String>, dim: usize, metric: DistanceMetric, ) -> Self
Add an HNSW vector field for similarity search.
HNSW (Hierarchical Navigable Small World) is an approximate nearest neighbors algorithm that provides fast queries with good recall.
§Arguments
name- Field namedim- Vector dimensionality (must match your embeddings)metric- Distance metric (L2, InnerProduct, or Cosine)
§Example
SearchIndex::new("docs", "crdt:docs:")
.vector_hnsw("embedding", 1536, DistanceMetric::Cosine)Sourcepub fn vector_hnsw_at(
self,
name: impl Into<String>,
json_path: impl Into<String>,
dim: usize,
metric: DistanceMetric,
) -> Self
pub fn vector_hnsw_at( self, name: impl Into<String>, json_path: impl Into<String>, dim: usize, metric: DistanceMetric, ) -> Self
Add an HNSW vector field with custom JSON path.
Sourcepub fn vector_with_params(
self,
name: impl Into<String>,
params: VectorParams,
) -> Self
pub fn vector_with_params( self, name: impl Into<String>, params: VectorParams, ) -> Self
Add an HNSW vector field with tuned parameters.
§Arguments
name- Field nameparams- Pre-configured VectorParams with custom M and EF_CONSTRUCTION
§Example
let params = VectorParams::hnsw(1536, DistanceMetric::Cosine)
.with_m(32)
.with_ef_construction(400);
SearchIndex::new("docs", "crdt:docs:")
.vector_with_params("embedding", params)Sourcepub fn vector_flat(
self,
name: impl Into<String>,
dim: usize,
metric: DistanceMetric,
) -> Self
pub fn vector_flat( self, name: impl Into<String>, dim: usize, metric: DistanceMetric, ) -> Self
Add a FLAT vector field for exact similarity search.
FLAT is a brute-force algorithm with O(n) query time but provides exact results. Good for smaller datasets (<10k vectors).
§Arguments
name- Field namedim- Vector dimensionality (must match your embeddings)metric- Distance metric (L2, InnerProduct, or Cosine)
Sourcepub fn vector_flat_at(
self,
name: impl Into<String>,
json_path: impl Into<String>,
dim: usize,
metric: DistanceMetric,
) -> Self
pub fn vector_flat_at( self, name: impl Into<String>, json_path: impl Into<String>, dim: usize, metric: DistanceMetric, ) -> Self
Add a FLAT vector field with custom JSON path.
Sourcepub fn to_ft_create_args(&self) -> Vec<String>
pub fn to_ft_create_args(&self) -> Vec<String>
Generate the FT.CREATE command arguments
Trait Implementations§
Source§impl Clone for SearchIndex
impl Clone for SearchIndex
Source§fn clone(&self) -> SearchIndex
fn clone(&self) -> SearchIndex
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SearchIndex
impl RefUnwindSafe for SearchIndex
impl Send for SearchIndex
impl Sync for SearchIndex
impl Unpin for SearchIndex
impl UnwindSafe for SearchIndex
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more