Key

Enum Key 

Source
pub enum Key {
    Document,
    Embedding,
    Metadata,
    Score,
    MetadataField(String),
}
Expand description

Represents a field key in search queries.

Used for both selecting fields to return and building filter expressions. Predefined keys access special fields, while custom keys access metadata.

§Predefined Keys

  • Key::Document - Document text content (#document)
  • Key::Embedding - Vector embeddings (#embedding)
  • Key::Metadata - All metadata fields (#metadata)
  • Key::Score - Search scores (#score)

§Custom Keys

Use Key::field() or Key::from() to reference metadata fields:

use chroma_types::operator::Key;

let key = Key::field("author");
let key = Key::from("title");

§Examples

§Building filters

use chroma_types::operator::Key;

// Equality
let filter = Key::field("status").eq("published");

// Comparisons
let filter = Key::field("year").gte(2020);
let filter = Key::field("score").lt(0.9);

// Set operations
let filter = Key::field("category").is_in(vec!["tech", "science"]);
let filter = Key::field("status").not_in(vec!["deleted", "archived"]);

// Document content
let filter = Key::Document.contains("machine learning");
let filter = Key::Document.regex(r"\bAPI\b");

// Combining filters
let filter = Key::field("status").eq("published")
    & Key::field("year").gte(2020);

§Selecting fields

use chroma_types::plan::SearchPayload;
use chroma_types::operator::Key;

let search = SearchPayload::default()
    .select([
        Key::Document,
        Key::Score,
        Key::field("title"),
        Key::field("author"),
    ]);

Variants§

§

Document

§

Embedding

§

Metadata

§

Score

§

MetadataField(String)

Implementations§

Source§

impl Key

Source

pub fn field(name: impl Into<String>) -> Key

Creates a Key for a custom metadata field.

§Examples
use chroma_types::operator::Key;

let status = Key::field("status");
let year = Key::field("year");
let author = Key::field("author");
Source

pub fn eq<T>(self, value: T) -> Where
where T: Into<MetadataValue>,

Creates an equality filter: field == value.

§Examples
use chroma_types::operator::Key;

// String equality
let filter = Key::field("status").eq("published");

// Numeric equality
let filter = Key::field("count").eq(42);

// Boolean equality
let filter = Key::field("featured").eq(true);
Source

pub fn ne<T>(self, value: T) -> Where
where T: Into<MetadataValue>,

Creates an inequality filter: field != value.

§Examples
use chroma_types::operator::Key;

let filter = Key::field("status").ne("deleted");
let filter = Key::field("count").ne(0);
Source

pub fn gt<T>(self, value: T) -> Where
where T: Into<MetadataValue>,

Creates a greater-than filter: field > value (numeric only).

§Examples
use chroma_types::operator::Key;

let filter = Key::field("score").gt(0.5);
let filter = Key::field("year").gt(2020);
Source

pub fn gte<T>(self, value: T) -> Where
where T: Into<MetadataValue>,

Creates a greater-than-or-equal filter: field >= value (numeric only).

§Examples
use chroma_types::operator::Key;

let filter = Key::field("score").gte(0.5);
let filter = Key::field("year").gte(2020);
Source

pub fn lt<T>(self, value: T) -> Where
where T: Into<MetadataValue>,

Creates a less-than filter: field < value (numeric only).

§Examples
use chroma_types::operator::Key;

let filter = Key::field("score").lt(0.9);
let filter = Key::field("year").lt(2025);
Source

pub fn lte<T>(self, value: T) -> Where
where T: Into<MetadataValue>,

Creates a less-than-or-equal filter: field <= value (numeric only).

§Examples
use chroma_types::operator::Key;

let filter = Key::field("score").lte(0.9);
let filter = Key::field("year").lte(2024);
Source

pub fn is_in<I, T>(self, values: I) -> Where
where I: IntoIterator<Item = T>, Vec<T>: Into<MetadataSetValue>,

Creates a set membership filter: field IN values.

Accepts any iterator (Vec, array, slice, etc.).

§Examples
use chroma_types::operator::Key;

// With Vec
let filter = Key::field("year").is_in(vec![2023, 2024, 2025]);

// With array
let filter = Key::field("category").is_in(["tech", "science", "math"]);

// With owned strings
let categories = vec!["tech".to_string(), "science".to_string()];
let filter = Key::field("category").is_in(categories);
Source

pub fn not_in<I, T>(self, values: I) -> Where
where I: IntoIterator<Item = T>, Vec<T>: Into<MetadataSetValue>,

Creates a set exclusion filter: field NOT IN values.

Accepts any iterator (Vec, array, slice, etc.).

§Examples
use chroma_types::operator::Key;

// Exclude deleted and archived
let filter = Key::field("status").not_in(vec!["deleted", "archived"]);

// Exclude specific years
let filter = Key::field("year").not_in(vec![2019, 2020]);
Source

pub fn contains<S>(self, text: S) -> Where
where S: Into<String>,

Creates a substring filter (case-sensitive, document content only).

Note: Currently only works with Key::Document. Pattern must have at least 3 literal characters for accurate results.

§Examples
use chroma_types::operator::Key;

let filter = Key::Document.contains("machine learning");
let filter = Key::Document.contains("API");
Source

pub fn not_contains<S>(self, text: S) -> Where
where S: Into<String>,

Creates a negative substring filter (case-sensitive, document content only).

Note: Currently only works with Key::Document.

§Examples
use chroma_types::operator::Key;

let filter = Key::Document.not_contains("deprecated");
let filter = Key::Document.not_contains("beta");
Source

pub fn regex<S>(self, pattern: S) -> Where
where S: Into<String>,

Creates a regex filter (case-sensitive, document content only).

Note: Currently only works with Key::Document. Pattern must have at least 3 literal characters for accurate results.

§Examples
use chroma_types::operator::Key;

// Match whole word "API"
let filter = Key::Document.regex(r"\bAPI\b");

// Match version pattern
let filter = Key::Document.regex(r"v\d+\.\d+\.\d+");
Source

pub fn not_regex<S>(self, pattern: S) -> Where
where S: Into<String>,

Creates a negative regex filter (case-sensitive, document content only).

Note: Currently only works with Key::Document.

§Examples
use chroma_types::operator::Key;

// Exclude beta versions
let filter = Key::Document.not_regex(r"beta");

// Exclude test documents
let filter = Key::Document.not_regex(r"\btest\b");

Trait Implementations§

Source§

impl Clone for Key

Source§

fn clone(&self) -> Key

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Key

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Key

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Key, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Key

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<&str> for Key

Source§

fn from(s: &str) -> Key

Converts to this type from the input type.
Source§

impl From<String> for Key

Source§

fn from(s: String) -> Key

Converts to this type from the input type.
Source§

impl Hash for Key

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Key

Source§

fn cmp(&self, other: &Key) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Key

Source§

fn eq(&self, other: &Key) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Key

Source§

fn partial_cmp(&self, other: &Key) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Key

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Key

Source§

impl StructuralPartialEq for Key

Auto Trait Implementations§

§

impl Freeze for Key

§

impl RefUnwindSafe for Key

§

impl Send for Key

§

impl Sync for Key

§

impl Unpin for Key

§

impl UnwindSafe for Key

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

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

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToString for T
where T: Display + ?Sized,

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ValidateIp for T
where T: ToString,

Source§

fn validate_ipv4(&self) -> bool

Validates whether the given string is an IP V4
Source§

fn validate_ipv6(&self) -> bool

Validates whether the given string is an IP V6
Source§

fn validate_ip(&self) -> bool

Validates whether the given string is an IP
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T