Struct google_api_proto::google::cloud::retail::v2::search_request::FacetSpec
source · pub struct FacetSpec {
pub facet_key: Option<FacetKey>,
pub limit: i32,
pub excluded_filter_keys: Vec<String>,
pub enable_dynamic_position: bool,
}
Expand description
A facet specification to perform faceted search.
Fields§
§facet_key: Option<FacetKey>
Required. The facet key specification.
limit: i32
Maximum of facet values that should be returned for this facet. If unspecified, defaults to 50. The maximum allowed value is 300. Values above 300 will be coerced to 300.
If this field is negative, an INVALID_ARGUMENT is returned.
excluded_filter_keys: Vec<String>
List of keys to exclude when faceting.
By default, [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] is not excluded from the filter unless it is listed in this field.
Listing a facet key in this field allows its values to appear as facet results, even when they are filtered out of search results. Using this field does not affect what search results are returned.
For example, suppose there are 100 products with the color facet “Red” and 200 products with the color facet “Blue”. A query containing the filter “colorFamilies:ANY(“Red”)“ and having “colorFamilies” as [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] would by default return only “Red” products in the search results, and also return “Red” with count 100 as the only color facet. Although there are also blue products available, “Blue” would not be shown as an available facet value.
If “colorFamilies” is listed in “excludedFilterKeys”, then the query returns the facet values “Red” with count 100 and “Blue” with count 200, because the “colorFamilies” key is now excluded from the filter. Because this field doesn’t affect search results, the search results are still correctly filtered to return only “Red” products.
A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error is returned.
enable_dynamic_position: bool
Enables dynamic position for this facet. If set to true, the position of this facet among all facets in the response is determined by Google Retail Search. It is ordered together with dynamic facets if dynamic facets is enabled. If set to false, the position of this facet in the response is the same as in the request, and it is ranked before the facets with dynamic position enable and all dynamic facets.
For example, you may always want to have rating facet returned in the response, but it’s not necessarily to always display the rating facet at the top. In that case, you can set enable_dynamic_position to true so that the position of rating facet in response is determined by Google Retail Search.
Another example, assuming you have the following facets in the request:
-
“rating”, enable_dynamic_position = true
-
“price”, enable_dynamic_position = false
-
“brands”, enable_dynamic_position = false
And also you have a dynamic facets enable, which generates a facet “gender”. Then, the final order of the facets in the response can be (“price”, “brands”, “rating”, “gender”) or (“price”, “brands”, “gender”, “rating”) depends on how Google Retail Search orders “gender” and “rating” facets. However, notice that “price” and “brands” are always ranked at first and second position because their enable_dynamic_position values are false.
Trait Implementations§
source§impl Message for FacetSpec
impl Message for FacetSpec
source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
. Read moresource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
.source§impl PartialEq for FacetSpec
impl PartialEq for FacetSpec
impl StructuralPartialEq for FacetSpec
Auto Trait Implementations§
impl Freeze for FacetSpec
impl RefUnwindSafe for FacetSpec
impl Send for FacetSpec
impl Sync for FacetSpec
impl Unpin for FacetSpec
impl UnwindSafe for FacetSpec
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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