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 Discovery Engine v1beta 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 automatically.
If dynamic facets are enabled, it is ordered together.
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
automatically.
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 enabled, 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 API orders "gender" and "rating" facets.
However, notice that "price" and "brands" are always
ranked at first and second position because their enable_dynamic_position
is false.
public RepeatedField<string> ExcludedFilterKeys { get; }
List of keys to exclude when faceting.
By default,
[FacetKey.key][google.cloud.discoveryengine.v1beta.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 documents with the color facet "Red"
and 200 documents with the color facet "Blue". A query containing the
filter "color:ANY("Red")" and having "color" as
[FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key]
would by default return only "Red" documents in the search results, and
also return "Red" with count 100 as the only color facet. Although there
are also blue documents available, "Blue" would not be shown as an
available facet value.
If "color" is listed in "excludedFilterKeys", then the query returns the
facet values "Red" with count 100 and "Blue" with count 200, because the
"color" 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" documents.
A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT
error is returned.
Maximum facet values that are returned for this facet. If
unspecified, defaults to 20. The maximum allowed value is 300. Values
above 300 are coerced to 300.
For aggregation in healthcare search, when the [FacetKey.key] is
"healthcare_aggregation_key", the limit will be overridden to
10,000 internally, regardless of the value set here.
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"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eSearchRequest.Types.FacetSpec\u003c/code\u003e class is part of the Discovery Engine v1beta API and is used to define a specification for performing faceted search.\u003c/p\u003e\n"],["\u003cp\u003eThis class inherits from \u003ccode\u003eobject\u003c/code\u003e and implements \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, providing functionality for message handling, equality checks, deep cloning, and buffered messaging.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eFacetSpec\u003c/code\u003e includes properties such as \u003ccode\u003eEnableDynamicPosition\u003c/code\u003e to control the automatic positioning of facets, \u003ccode\u003eExcludedFilterKeys\u003c/code\u003e to list facet keys excluded from filtering, and \u003ccode\u003eFacetKey\u003c/code\u003e to define the facet key specification.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eLimit\u003c/code\u003e property in \u003ccode\u003eFacetSpec\u003c/code\u003e determines the maximum number of facet values returned, with a default of 20 and a maximum allowed value of 300, except for healthcare aggregation keys where the limit is internally overridden to 10,000.\u003c/p\u003e\n"],["\u003cp\u003eThere are two constructors, \u003ccode\u003eFacetSpec()\u003c/code\u003e, which is parameterless and \u003ccode\u003eFacetSpec(SearchRequest.Types.FacetSpec other)\u003c/code\u003e, which copies a \u003ccode\u003eSearchRequest.Types.FacetSpec\u003c/code\u003e instance.\u003c/p\u003e\n"]]],[],null,["# Discovery Engine v1beta API - Class SearchRequest.Types.FacetSpec (1.0.0-beta19)\n\nVersion latestkeyboard_arrow_down\n\n- [1.0.0-beta19 (latest)](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.SearchRequest.Types.FacetSpec)\n- [1.0.0-beta18](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/1.0.0-beta18/Google.Cloud.DiscoveryEngine.V1Beta.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 Discovery Engine v1beta 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.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.SearchRequest)[Types](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.SearchRequest.Types)[FacetSpec](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.SearchRequest.Types.FacetSpec), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[SearchRequest](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.SearchRequest)[Types](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.SearchRequest.Types)[FacetSpec](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.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.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.SearchRequest)[Types](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.SearchRequest.Types)[FacetSpec](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.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.DiscoveryEngine.V1Beta](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta)\n\nAssembly\n--------\n\nGoogle.Cloud.DiscoveryEngine.V1Beta.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 automatically.\nIf dynamic facets are enabled, it is ordered together.\nIf 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\nautomatically.\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 enabled, 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 API orders \"gender\" and \"rating\" facets.\nHowever, notice that \"price\" and \"brands\" are always\nranked at first and second position because their enable_dynamic_position\nis 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.discoveryengine.v1beta.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 documents with the color facet \"Red\"\nand 200 documents with the color facet \"Blue\". A query containing the\nfilter \"color:ANY(\"Red\")\" and having \"color\" as\n\\[FacetKey.key\\]\\[google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key\\]\nwould by default return only \"Red\" documents in the search results, and\nalso return \"Red\" with count 100 as the only color facet. Although there\nare also blue documents available, \"Blue\" would not be shown as an\navailable facet value.\n\nIf \"color\" is listed in \"excludedFilterKeys\", then the query returns the\nfacet values \"Red\" with count 100 and \"Blue\" with count 200, because the\n\"color\" key is now excluded from the filter. Because this field doesn't\naffect search results, the search results are still correctly filtered to\nreturn only \"Red\" documents.\n\nA maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT`\nerror is 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 facet values that are returned for this facet. If\nunspecified, defaults to 20. The maximum allowed value is 300. Values\nabove 300 are coerced to 300.\nFor aggregation in healthcare search, when the \\[FacetKey.key\\] is\n\"healthcare_aggregation_key\", the limit will be overridden to\n10,000 internally, regardless of the value set here.\n\nIf this field is negative, an `INVALID_ARGUMENT` is returned."]]