public sealed class SearchRequest.Types.FacetSpec : IMessage<SearchRequest.Types.FacetSpec>, IEquatable<SearchRequest.Types.FacetSpec>, IDeepCloneable<SearchRequest.Types.FacetSpec>, IBufferMessage, IMessage
Reference documentation and code samples for the Retail v2 API class SearchRequest.Types.FacetSpec.
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.
public RepeatedField<string> ExcludedFilterKeys { get; }
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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThe document provides reference documentation for the \u003ccode\u003eSearchRequest.Types.FacetSpec\u003c/code\u003e class within the Google Cloud Retail v2 API, detailing its usage in faceted searches.\u003c/p\u003e\n"],["\u003cp\u003eThis \u003ccode\u003eFacetSpec\u003c/code\u003e class implements multiple interfaces like \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, allowing it to be used within the Google Protobuf system.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eFacetSpec\u003c/code\u003e class offers properties like \u003ccode\u003eEnableDynamicPosition\u003c/code\u003e, \u003ccode\u003eExcludedFilterKeys\u003c/code\u003e, \u003ccode\u003eFacetKey\u003c/code\u003e, and \u003ccode\u003eLimit\u003c/code\u003e to configure how facets are handled, such as dynamic positioning, filter exclusions, and value limits.\u003c/p\u003e\n"],["\u003cp\u003eThere are multiple versions of the \u003ccode\u003eSearchRequest.Types.FacetSpec\u003c/code\u003e class listed from 1.0.0 to the latest version 2.12.0, showing its evolution and support for different API versions.\u003c/p\u003e\n"],["\u003cp\u003eThe document provides details on the constructors and properties, including their descriptions, types, and how they influence the behavior of faceted searches.\u003c/p\u003e\n"]]],[],null,["# Retail v2 API - Class SearchRequest.Types.FacetSpec (2.14.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.14.0 (latest)](/dotnet/docs/reference/Google.Cloud.Retail.V2/latest/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.13.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.13.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.12.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.12.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.11.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.11.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.10.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.10.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.9.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.9.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.8.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.8.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.7.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.7.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.6.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.6.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.5.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.4.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.3.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.2.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.2.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.1.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.1.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [2.0.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/2.0.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [1.6.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/1.6.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [1.5.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/1.5.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [1.4.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/1.4.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [1.3.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/1.3.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [1.2.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/1.2.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [1.1.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/1.1.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec)\n- [1.0.0](/dotnet/docs/reference/Google.Cloud.Retail.V2/1.0.0/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec) \n\n public sealed class SearchRequest.Types.FacetSpec : IMessage\u003cSearchRequest.Types.FacetSpec\u003e, IEquatable\u003cSearchRequest.Types.FacetSpec\u003e, IDeepCloneable\u003cSearchRequest.Types.FacetSpec\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Retail v2 API class SearchRequest.Types.FacetSpec.\n\nA facet specification to perform faceted search. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e SearchRequest.Types.FacetSpec \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[SearchRequest](/dotnet/docs/reference/Google.Cloud.Retail.V2/latest/Google.Cloud.Retail.V2.SearchRequest)[Types](/dotnet/docs/reference/Google.Cloud.Retail.V2/latest/Google.Cloud.Retail.V2.SearchRequest.Types)[FacetSpec](/dotnet/docs/reference/Google.Cloud.Retail.V2/latest/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[SearchRequest](/dotnet/docs/reference/Google.Cloud.Retail.V2/latest/Google.Cloud.Retail.V2.SearchRequest)[Types](/dotnet/docs/reference/Google.Cloud.Retail.V2/latest/Google.Cloud.Retail.V2.SearchRequest.Types)[FacetSpec](/dotnet/docs/reference/Google.Cloud.Retail.V2/latest/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[SearchRequest](/dotnet/docs/reference/Google.Cloud.Retail.V2/latest/Google.Cloud.Retail.V2.SearchRequest)[Types](/dotnet/docs/reference/Google.Cloud.Retail.V2/latest/Google.Cloud.Retail.V2.SearchRequest.Types)[FacetSpec](/dotnet/docs/reference/Google.Cloud.Retail.V2/latest/Google.Cloud.Retail.V2.SearchRequest.Types.FacetSpec), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Retail.V2](/dotnet/docs/reference/Google.Cloud.Retail.V2/latest/Google.Cloud.Retail.V2)\n\nAssembly\n--------\n\nGoogle.Cloud.Retail.V2.dll\n\nConstructors\n------------\n\n### FacetSpec()\n\n public FacetSpec()\n\n### FacetSpec(FacetSpec)\n\n public FacetSpec(SearchRequest.Types.FacetSpec other)\n\nProperties\n----------\n\n### EnableDynamicPosition\n\n public bool EnableDynamicPosition { get; set; }\n\nEnables dynamic position for this facet. If set to true, the position of\nthis facet among all facets in the response is determined by Google\nRetail Search. It is ordered together with dynamic facets if dynamic\nfacets is enabled. If set to false, the position of this facet in the\nresponse is the same as in the request, and it is ranked before\nthe facets with dynamic position enable and all dynamic facets.\n\nFor example, you may always want to have rating facet returned in\nthe response, but it's not necessarily to always display the rating facet\nat the top. In that case, you can set enable_dynamic_position to true so\nthat the position of rating facet in response is determined by\nGoogle Retail Search.\n\nAnother example, assuming you have the following facets in the request:\n\n- \"rating\", enable_dynamic_position = true\n\n- \"price\", enable_dynamic_position = false\n\n- \"brands\", enable_dynamic_position = false\n\nAnd also you have a dynamic facets enable, which generates a facet\n\"gender\". Then, the final order of the facets in the response can be\n(\"price\", \"brands\", \"rating\", \"gender\") or (\"price\", \"brands\", \"gender\",\n\"rating\") depends on how Google Retail Search orders \"gender\" and\n\"rating\" facets. However, notice that \"price\" and \"brands\" are always\nranked at first and second position because their enable_dynamic_position\nvalues are false.\n\n### ExcludedFilterKeys\n\n public RepeatedField\u003cstring\u003e ExcludedFilterKeys { get; }\n\nList of keys to exclude when faceting.\n\nBy default,\n\\[FacetKey.key\\]\\[google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key\\]\nis not excluded from the filter unless it is listed in this field.\n\nListing a facet key in this field allows its values to appear as facet\nresults, even when they are filtered out of search results. Using this\nfield does not affect what search results are returned.\n\nFor example, suppose there are 100 products with the color facet \"Red\"\nand 200 products with the color facet \"Blue\". A query containing the\nfilter \"colorFamilies:ANY(\"Red\")\" and having \"colorFamilies\" as\n\\[FacetKey.key\\]\\[google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key\\]\nwould by default return only \"Red\" products in the search results, and\nalso return \"Red\" with count 100 as the only color facet. Although there\nare also blue products available, \"Blue\" would not be shown as an\navailable facet value.\n\nIf \"colorFamilies\" is listed in \"excludedFilterKeys\", then the query\nreturns the facet values \"Red\" with count 100 and \"Blue\" with count\n200, because the \"colorFamilies\" key is now excluded from the filter.\nBecause this field doesn't affect search results, the search results\nare still correctly filtered to return only \"Red\" products.\n\nA maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error\nis returned.\n\n### FacetKey\n\n public SearchRequest.Types.FacetSpec.Types.FacetKey FacetKey { get; set; }\n\nRequired. The facet key specification.\n\n### Limit\n\n public int Limit { get; set; }\n\nMaximum of facet values that should be returned for this facet. If\nunspecified, defaults to 50. The maximum allowed value is 300. Values\nabove 300 will be coerced to 300.\n\nIf this field is negative, an INVALID_ARGUMENT is returned."]]