public sealed class RecommendRequest : IMessage<RecommendRequest>, IEquatable<RecommendRequest>, IDeepCloneable<RecommendRequest>, IBufferMessage, IMessage
Reference documentation and code samples for the Discovery Engine v1beta API class RecommendRequest.
Filter for restricting recommendation results with a length limit of 5,000
characters. Currently, only filter expressions on the filter_tags
attribute is supported.
Examples:
(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))
(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))
If attributeFilteringSyntax is set to true under the params field, then
attribute-based expressions are expected instead of the above described
tag-based syntax. Examples:
(launguage: ANY("en", "es")) AND NOT (categories: ANY("Movie"))
(available: true) AND
(launguage: ANY("en", "es")) OR (categories: ANY("Movie"))
If your filter blocks all results, the API returns generic
(unfiltered) popular Documents. If you only want results strictly matching
the filters, set strictFiltering to true in
[RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]
to receive empty results instead.
Note that the API never returns
[Document][google.cloud.discoveryengine.v1beta.Document]s with
storageStatus as EXPIRED or DELETED regardless of filter choices.
Maximum number of results to return. Set this property
to the number of recommendation results needed. If zero, the service
chooses a reasonable default. The maximum allowed value is 100. Values
above 100 are set to 100.
Additional domain specific parameters for the recommendations.
Allowed values:
returnDocument: Boolean. If set to true, the associated Document
object is returned in
[RecommendResponse.RecommendationResult.document][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document].
returnScore: Boolean. If set to true, the recommendation score
corresponding to each returned Document is set in
[RecommendResponse.RecommendationResult.metadata][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata].
The given score indicates the probability of a Document conversion given
the user's context and history.
strictFiltering: Boolean. True by default. If set to false, the
service
returns generic (unfiltered) popular Documents instead of empty if
your filter blocks all recommendation results.
diversityLevel: String. Default empty. If set to be non-empty, then
it needs to be one of:
no-diversity
low-diversity
medium-diversity
high-diversity
auto-diversity
This gives request-level control and adjusts recommendation results
based on Document category.
attributeFilteringSyntax: Boolean. False by default. If set to true,
the filter field is interpreted according to the new,
attribute-based syntax.
Required. Full resource name of a
[ServingConfig][google.cloud.discoveryengine.v1beta.ServingConfig]:
projects/*/locations/global/collections/*/engines/*/servingConfigs/*, or
projects/*/locations/global/collections/*/dataStores/*/servingConfigs/*
One default serving config is created along with your recommendation engine
creation. The engine ID is used as the ID of the default serving
config. For example, for Engine
projects/*/locations/global/collections/*/engines/my-engine, you can use
projects/*/locations/global/collections/*/engines/my-engine/servingConfigs/my-engine
for your
[RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]
requests.
Required. Context about the user, what they are looking at and what action
they took to trigger the Recommend request. Note that this user event
detail won't be ingested to userEvent logs. Thus, a separate userEvent
write request is required for event logging.
Don't set
[UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id]
or
[UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id]
to the same fixed ID for different users. If you are trying to receive
non-personalized recommendations (not recommended; this can negatively
impact model performance), instead set
[UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id]
to a random unique ID and leave
[UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id]
unset.
public MapField<string, string> UserLabels { get; }
The user labels applied to a resource must meet the following requirements:
Each resource can have multiple labels, up to a maximum of 64.
Each label must be a key-value pair.
Keys have a minimum length of 1 character and a maximum length of 63
characters and cannot be empty. Values can be empty and have a maximum
length of 63 characters.
Keys and values can contain only lowercase letters, numeric characters,
underscores, and dashes. All characters must use UTF-8 encoding, and
international characters are allowed.
The key portion of a label must be unique. However, you can use the same
key with multiple resources.
Keys must start with a lowercase letter or international character.
Use validate only mode for this recommendation query. If set to true, a
fake model is used that returns arbitrary Document IDs.
Note that the validate only mode should only be used for testing the API,
or if the model is not ready.
[[["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\u003eThis document describes the \u003ccode\u003eRecommendRequest\u003c/code\u003e class within the Google Cloud Discovery Engine v1beta API, detailing its purpose as a request message for the \u003ccode\u003eRecommend\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eRecommendRequest\u003c/code\u003e allows for result filtering based on tags or attributes, with options for strict filtering and the possibility of receiving generic results if filters block all recommendations.\u003c/p\u003e\n"],["\u003cp\u003eThe class supports setting parameters such as \u003ccode\u003ePageSize\u003c/code\u003e to control the number of results returned, and \u003ccode\u003eParams\u003c/code\u003e to specify additional domain-specific settings like returning the associated \u003ccode\u003eDocument\u003c/code\u003e or enabling attribute filtering syntax.\u003c/p\u003e\n"],["\u003cp\u003eIt requires a \u003ccode\u003eServingConfig\u003c/code\u003e to be specified, which is a resource name pointing to a specific serving configuration within the Discovery Engine.\u003c/p\u003e\n"],["\u003cp\u003eThe class allows the specification of a \u003ccode\u003eUserEvent\u003c/code\u003e which should contain information about the user and the event that triggered the request, and also allows the option to add \u003ccode\u003eUserLabels\u003c/code\u003e to the resource, as well as to perform a validation.\u003c/p\u003e\n"]]],[],null,["# Discovery Engine v1beta API - Class RecommendRequest (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.RecommendRequest)\n- [1.0.0-beta18](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/1.0.0-beta18/Google.Cloud.DiscoveryEngine.V1Beta.RecommendRequest) \n\n public sealed class RecommendRequest : IMessage\u003cRecommendRequest\u003e, IEquatable\u003cRecommendRequest\u003e, IDeepCloneable\u003cRecommendRequest\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Discovery Engine v1beta API class RecommendRequest.\n\nRequest message for Recommend method. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e RecommendRequest \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[RecommendRequest](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.RecommendRequest), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[RecommendRequest](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.RecommendRequest), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[RecommendRequest](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.RecommendRequest), [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### RecommendRequest()\n\n public RecommendRequest()\n\n### RecommendRequest(RecommendRequest)\n\n public RecommendRequest(RecommendRequest other)\n\nProperties\n----------\n\n### Filter\n\n public string Filter { get; set; }\n\nFilter for restricting recommendation results with a length limit of 5,000\ncharacters. Currently, only filter expressions on the `filter_tags`\nattribute is supported.\n\nExamples:\n\n- `(filter_tags: ANY(\"Red\", \"Blue\") OR filter_tags: ANY(\"Hot\", \"Cold\"))`\n- `(filter_tags: ANY(\"Red\", \"Blue\")) AND NOT (filter_tags: ANY(\"Green\"))`\n\nIf `attributeFilteringSyntax` is set to true under the `params` field, then\nattribute-based expressions are expected instead of the above described\ntag-based syntax. Examples:\n\n- (launguage: ANY(\"en\", \"es\")) AND NOT (categories: ANY(\"Movie\"))\n- (available: true) AND (launguage: ANY(\"en\", \"es\")) OR (categories: ANY(\"Movie\"))\n\nIf your filter blocks all results, the API returns generic\n(unfiltered) popular Documents. If you only want results strictly matching\nthe filters, set `strictFiltering` to `true` in\n\\[RecommendRequest.params\\]\\[google.cloud.discoveryengine.v1beta.RecommendRequest.params\\]\nto receive empty results instead.\n\nNote that the API never returns\n\\[Document\\]\\[google.cloud.discoveryengine.v1beta.Document\\]s with\n`storageStatus` as `EXPIRED` or `DELETED` regardless of filter choices.\n\n### PageSize\n\n public int PageSize { get; set; }\n\nMaximum number of results to return. Set this property\nto the number of recommendation results needed. If zero, the service\nchooses a reasonable default. The maximum allowed value is 100. Values\nabove 100 are set to 100.\n\n### Params\n\n public MapField\u003cstring, Value\u003e Params { get; }\n\nAdditional domain specific parameters for the recommendations.\n\nAllowed values:\n\n- `returnDocument`: Boolean. If set to `true`, the associated Document object is returned in \\[RecommendResponse.RecommendationResult.document\\]\\[google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document\\].\n- `returnScore`: Boolean. If set to true, the recommendation score corresponding to each returned Document is set in \\[RecommendResponse.RecommendationResult.metadata\\]\\[google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata\\]. The given score indicates the probability of a Document conversion given the user's context and history.\n- `strictFiltering`: Boolean. True by default. If set to `false`, the service returns generic (unfiltered) popular Documents instead of empty if your filter blocks all recommendation results.\n- `diversityLevel`: String. Default empty. If set to be non-empty, then it needs to be one of:\n - `no-diversity`\n - `low-diversity`\n - `medium-diversity`\n - `high-diversity`\n - `auto-diversity` This gives request-level control and adjusts recommendation results based on Document category.\n- `attributeFilteringSyntax`: Boolean. False by default. If set to true, the `filter` field is interpreted according to the new, attribute-based syntax.\n\n### ServingConfig\n\n public string ServingConfig { get; set; }\n\nRequired. Full resource name of a\n\\[ServingConfig\\]\\[google.cloud.discoveryengine.v1beta.ServingConfig\\]:\n`projects/*/locations/global/collections/*/engines/*/servingConfigs/*`, or\n`projects/*/locations/global/collections/*/dataStores/*/servingConfigs/*`\n\nOne default serving config is created along with your recommendation engine\ncreation. The engine ID is used as the ID of the default serving\nconfig. For example, for Engine\n`projects/*/locations/global/collections/*/engines/my-engine`, you can use\n`projects/*/locations/global/collections/*/engines/my-engine/servingConfigs/my-engine`\nfor your\n\\[RecommendationService.Recommend\\]\\[google.cloud.discoveryengine.v1beta.RecommendationService.Recommend\\]\nrequests.\n\n### ServingConfigAsServingConfigName\n\n public ServingConfigName ServingConfigAsServingConfigName { get; set; }\n\n[ServingConfigName](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.ServingConfigName)-typed view over the [ServingConfig](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1Beta/latest/Google.Cloud.DiscoveryEngine.V1Beta.RecommendRequest#Google_Cloud_DiscoveryEngine_V1Beta_RecommendRequest_ServingConfig) resource name property.\n\n### UserEvent\n\n public UserEvent UserEvent { get; set; }\n\nRequired. Context about the user, what they are looking at and what action\nthey took to trigger the Recommend request. Note that this user event\ndetail won't be ingested to userEvent logs. Thus, a separate userEvent\nwrite request is required for event logging.\n\nDon't set\n\\[UserEvent.user_pseudo_id\\]\\[google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id\\]\nor\n\\[UserEvent.user_info.user_id\\]\\[google.cloud.discoveryengine.v1beta.UserInfo.user_id\\]\nto the same fixed ID for different users. If you are trying to receive\nnon-personalized recommendations (not recommended; this can negatively\nimpact model performance), instead set\n\\[UserEvent.user_pseudo_id\\]\\[google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id\\]\nto a random unique ID and leave\n\\[UserEvent.user_info.user_id\\]\\[google.cloud.discoveryengine.v1beta.UserInfo.user_id\\]\nunset.\n\n### UserLabels\n\n public MapField\u003cstring, string\u003e UserLabels { get; }\n\nThe user labels applied to a resource must meet the following requirements:\n\n- Each resource can have multiple labels, up to a maximum of 64.\n- Each label must be a key-value pair.\n- Keys have a minimum length of 1 character and a maximum length of 63 characters and cannot be empty. Values can be empty and have a maximum length of 63 characters.\n- Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed.\n- The key portion of a label must be unique. However, you can use the same key with multiple resources.\n- Keys must start with a lowercase letter or international character.\n\nSee [Requirements for\nlabels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)\nfor more details.\n\n### ValidateOnly\n\n public bool ValidateOnly { get; set; }\n\nUse validate only mode for this recommendation query. If set to `true`, a\nfake model is used that returns arbitrary Document IDs.\nNote that the validate only mode should only be used for testing the API,\nor if the model is not ready."]]