#[non_exhaustive]pub struct FacetKey {
pub key: String,
pub intervals: Vec<Interval>,
pub restricted_values: Vec<String>,
pub prefixes: Vec<String>,
pub contains: Vec<String>,
pub case_insensitive: bool,
pub order_by: String,
/* private fields */
}assistant-service or conversational-search-service or search-service or serving-config-service only.Expand description
Specifies how a facet is computed.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.key: StringRequired. Supported textual and numerical facet keys in Document object, over which the facet values are computed. Facet key is case-sensitive.
intervals: Vec<Interval>Set only if values should be bucketed into intervals. Must be set for facets with numerical values. Must not be set for facet with text values. Maximum number of intervals is 30.
restricted_values: Vec<String>Only get facet for the given restricted values. Only supported on textual fields. For example, suppose “category” has three values “Action > 2022”, “Action > 2021” and “Sci-Fi > 2022”. If set “restricted_values” to “Action > 2022”, the “category” facet only contains “Action > 2022”. Only supported on textual fields. Maximum is 10.
prefixes: Vec<String>Only get facet values that start with the given string prefix. For example, suppose “category” has three values “Action > 2022”, “Action > 2021” and “Sci-Fi > 2022”. If set “prefixes” to “Action”, the “category” facet only contains “Action > 2022” and “Action > 2021”. Only supported on textual fields. Maximum is 10.
contains: Vec<String>Only get facet values that contain the given strings. For example, suppose “category” has three values “Action > 2022”, “Action > 2021” and “Sci-Fi > 2022”. If set “contains” to “2022”, the “category” facet only contains “Action > 2022” and “Sci-Fi > 2022”. Only supported on textual fields. Maximum is 10.
case_insensitive: boolTrue to make facet keys case insensitive when getting faceting values with prefixes or contains; false otherwise.
order_by: StringThe order in which documents are returned.
Allowed values are:
-
“count desc”, which means order by SearchResponse.Facet.values.count descending.
-
“value desc”, which means order by SearchResponse.Facet.values.value descending. Only applies to textual facets.
If not set, textual values are sorted in natural order; numerical intervals are sorted in the order given by FacetSpec.FacetKey.intervals.
Implementations§
Source§impl FacetKey
impl FacetKey
Sourcepub fn set_intervals<T, V>(self, v: T) -> Self
pub fn set_intervals<T, V>(self, v: T) -> Self
Sourcepub fn set_restricted_values<T, V>(self, v: T) -> Self
pub fn set_restricted_values<T, V>(self, v: T) -> Self
Sets the value of restricted_values.
§Example
let x = FacetKey::new().set_restricted_values(["a", "b", "c"]);Sourcepub fn set_prefixes<T, V>(self, v: T) -> Self
pub fn set_prefixes<T, V>(self, v: T) -> Self
Sourcepub fn set_contains<T, V>(self, v: T) -> Self
pub fn set_contains<T, V>(self, v: T) -> Self
Sourcepub fn set_case_insensitive<T: Into<bool>>(self, v: T) -> Self
pub fn set_case_insensitive<T: Into<bool>>(self, v: T) -> Self
Trait Implementations§
impl StructuralPartialEq for FacetKey
Auto Trait Implementations§
impl Freeze for FacetKey
impl RefUnwindSafe for FacetKey
impl Send for FacetKey
impl Sync for FacetKey
impl Unpin for FacetKey
impl UnsafeUnpin for FacetKey
impl UnwindSafe for FacetKey
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request