pub struct VectorSetClient<'a, C> { /* private fields */ }vector only.Expand description
High-level client for Vector Set operations, bound to a single key.
Holds a mutable borrow of an underlying RedisExecutor and a vector set
key, exposing typed add/query/introspection operations over the elements of
that set.
Implementations§
Source§impl<'a, C: RedisExecutor> VectorSetClient<'a, C>
impl<'a, C: RedisExecutor> VectorSetClient<'a, C>
Sourcepub fn new(conn: &'a mut C, key: impl Into<CommandArg>) -> Self
pub fn new(conn: &'a mut C, key: impl Into<CommandArg>) -> Self
Create a new VectorSetClient for key, borrowing conn.
Sourcepub async fn add(
&mut self,
vector: Vec<f32>,
element: impl Into<CommandArg>,
) -> Result<bool, RedisError>
pub async fn add( &mut self, vector: Vec<f32>, element: impl Into<CommandArg>, ) -> Result<bool, RedisError>
Add or update a vector element. Returns true if the element was newly
added, false if an existing element was updated.
Sourcepub async fn add_with_options(
&mut self,
vector: Vec<f32>,
element: impl Into<CommandArg>,
options: VAddOptions,
) -> Result<bool, RedisError>
pub async fn add_with_options( &mut self, vector: Vec<f32>, element: impl Into<CommandArg>, options: VAddOptions, ) -> Result<bool, RedisError>
Add or update a vector element with explicit VAddOptions.
Sourcepub async fn remove(
&mut self,
element: impl Into<CommandArg>,
) -> Result<bool, RedisError>
pub async fn remove( &mut self, element: impl Into<CommandArg>, ) -> Result<bool, RedisError>
Remove an element. Returns true if it existed and was removed.
Sourcepub async fn search(
&mut self,
query: VectorQuery,
) -> Result<Vec<SimilarityResult>, RedisError>
pub async fn search( &mut self, query: VectorQuery, ) -> Result<Vec<SimilarityResult>, RedisError>
Find the elements most similar to the query target.
Sourcepub async fn embedding(
&mut self,
element: impl Into<CommandArg>,
) -> Result<Vec<f64>, RedisError>
pub async fn embedding( &mut self, element: impl Into<CommandArg>, ) -> Result<Vec<f64>, RedisError>
Retrieve the embedding (vector) for an element.
Sourcepub async fn links(
&mut self,
element: impl Into<CommandArg>,
) -> Result<Vec<SimilarityResult>, RedisError>
pub async fn links( &mut self, element: impl Into<CommandArg>, ) -> Result<Vec<SimilarityResult>, RedisError>
Return the neighbour links of an element, with similarity scores.
Sourcepub async fn random(
&mut self,
count: Option<i64>,
) -> Result<Vec<Bytes>, RedisError>
pub async fn random( &mut self, count: Option<i64>, ) -> Result<Vec<Bytes>, RedisError>
Return one or more random elements from the set. A negative count
allows duplicates.
Sourcepub async fn set_attr(
&mut self,
element: impl Into<CommandArg>,
json: &str,
) -> Result<bool, RedisError>
pub async fn set_attr( &mut self, element: impl Into<CommandArg>, json: &str, ) -> Result<bool, RedisError>
Set a JSON attribute string on an element. Returns true on success.
Sourcepub async fn get_attr(
&mut self,
element: impl Into<CommandArg>,
) -> Result<Option<String>, RedisError>
pub async fn get_attr( &mut self, element: impl Into<CommandArg>, ) -> Result<Option<String>, RedisError>
Get the JSON attribute string for an element, or None if unset.
Sourcepub async fn del_attr(
&mut self,
element: impl Into<CommandArg>,
) -> Result<bool, RedisError>
pub async fn del_attr( &mut self, element: impl Into<CommandArg>, ) -> Result<bool, RedisError>
Clear the attribute on an element. Redis has no VDELATTR, so this sets
the attribute to the empty string via VSETATTR. Returns true if the
element exists, false if it is not in the set.
Sourcepub async fn cardinality(&mut self) -> Result<i64, RedisError>
pub async fn cardinality(&mut self) -> Result<i64, RedisError>
Return the number of elements in the set.
Sourcepub async fn dimensions(&mut self) -> Result<i64, RedisError>
pub async fn dimensions(&mut self) -> Result<i64, RedisError>
Return the dimensionality of the vectors in the set.
Sourcepub async fn info(&mut self) -> Result<VectorSetInfo, RedisError>
pub async fn info(&mut self) -> Result<VectorSetInfo, RedisError>
Return structured information about the set.
Sourcepub async fn set_attr_typed<T: Serialize>(
&mut self,
element: impl Into<CommandArg>,
attr: &T,
) -> Result<bool, RedisError>
Available on crate feature serde only.
pub async fn set_attr_typed<T: Serialize>( &mut self, element: impl Into<CommandArg>, attr: &T, ) -> Result<bool, RedisError>
serde only.Set a typed attribute on an element, serializing with serde_json.
Sourcepub async fn get_attr_typed<T: DeserializeOwned>(
&mut self,
element: impl Into<CommandArg>,
) -> Result<Option<T>, RedisError>
Available on crate feature serde only.
pub async fn get_attr_typed<T: DeserializeOwned>( &mut self, element: impl Into<CommandArg>, ) -> Result<Option<T>, RedisError>
serde only.Get a typed attribute from an element, deserializing with serde_json.
Returns None if no attribute is set.