Synchronously creates a RankServiceClient using the default credentials, endpoint and
settings. To specify custom credentials or other settings, use RankServiceClientBuilder.
public static Task<RankServiceClient> CreateAsync(CancellationToken cancellationToken = default)
Asynchronously creates a RankServiceClient using the default credentials, endpoint and
settings. To specify custom credentials or other settings, use RankServiceClientBuilder.
// Create client
RankServiceClient rankServiceClient = await RankServiceClient.CreateAsync();
// Initialize request argument(s)
RankRequest request = new RankRequest
{
RankingConfigAsRankingConfigName = RankingConfigName.FromProjectLocationRankingConfig("[PROJECT]", "[LOCATION]", "[RANKING_CONFIG]"),
Model = "",
TopN = 0,
Query = "",
Records =
{
new RankingRecord(),
},
IgnoreRecordDetailsInResponse = false,
UserLabels = { { "", "" }, },
};
// Make the request
RankResponse response = await rankServiceClient.RankAsync(request);
ShutdownDefaultChannelsAsync()
public static Task ShutdownDefaultChannelsAsync()
Shuts down any channels automatically created by Create() and
CreateAsync(CancellationToken). Channels which weren't automatically created are not
affected.
A task representing the asynchronous shutdown operation.
Remarks
After calling this method, further calls to Create() and
CreateAsync(CancellationToken) will create new channels, which could in turn be shut down
by another call to this method.
[[["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-08-28 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eRankServiceClient\u003c/code\u003e class, part of the Google Cloud Discovery Engine v1 API, provides methods for interacting with the RankService, including synchronous and asynchronous client creation.\u003c/p\u003e\n"],["\u003cp\u003eThis service is designed for ranking text records based on a given query, with the \u003ccode\u003eRank\u003c/code\u003e and \u003ccode\u003eRankAsync\u003c/code\u003e methods, allowing the user to send \u003ccode\u003eRankRequest\u003c/code\u003e objects and receive \u003ccode\u003eRankResponse\u003c/code\u003e objects in return.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version of this RankServiceClient is 1.6.0, and the service can be configured with custom credentials and settings via the \u003ccode\u003eRankServiceClientBuilder\u003c/code\u003e, using default credentials, endpoint and settings if not otherwise specified.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRankServiceClient\u003c/code\u003e utilizes gRPC for communication and includes methods to manage gRPC channels, such as \u003ccode\u003eShutdownDefaultChannelsAsync\u003c/code\u003e, to ensure efficient resource management, and it supports default scopes for cloud platform authentication.\u003c/p\u003e\n"],["\u003cp\u003eThe RankServiceClient has default properties such as DefaultEndpoint, which sets the host and port, as well as DefaultScopes, used for authorization when accessing the service.\u003c/p\u003e\n"]]],[],null,["# Discovery Engine v1 API - Class RankServiceClient (1.9.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.9.0 (latest)](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/latest/Google.Cloud.DiscoveryEngine.V1.RankServiceClient)\n- [1.8.0](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/1.8.0/Google.Cloud.DiscoveryEngine.V1.RankServiceClient)\n- [1.7.0](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/1.7.0/Google.Cloud.DiscoveryEngine.V1.RankServiceClient)\n- [1.6.0](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/1.6.0/Google.Cloud.DiscoveryEngine.V1.RankServiceClient)\n- [1.5.0](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/1.5.0/Google.Cloud.DiscoveryEngine.V1.RankServiceClient)\n- [1.4.0](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/1.4.0/Google.Cloud.DiscoveryEngine.V1.RankServiceClient)\n- [1.3.0](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/1.3.0/Google.Cloud.DiscoveryEngine.V1.RankServiceClient)\n- [1.2.0](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/1.2.0/Google.Cloud.DiscoveryEngine.V1.RankServiceClient)\n- [1.1.0](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/1.1.0/Google.Cloud.DiscoveryEngine.V1.RankServiceClient)\n- [1.0.0-beta06](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/1.0.0-beta06/Google.Cloud.DiscoveryEngine.V1.RankServiceClient) \n\n public abstract class RankServiceClient\n\nReference documentation and code samples for the Discovery Engine v1 API class RankServiceClient.\n\nRankService client wrapper, for convenient use. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e RankServiceClient \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.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring) \n\nDerived Types\n-------------\n\n[RankServiceClientImpl](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/latest/Google.Cloud.DiscoveryEngine.V1.RankServiceClientImpl)\n\nNamespace\n---------\n\n[Google.Cloud.DiscoveryEngine.V1](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/latest/Google.Cloud.DiscoveryEngine.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.DiscoveryEngine.V1.dll\n\nRemarks\n-------\n\nService for ranking text records.\n\nProperties\n----------\n\n### DefaultEndpoint\n\n public static string DefaultEndpoint { get; }\n\nThe default endpoint for the RankService service, which is a host of \"discoveryengine.googleapis.com\" and a\nport of 443.\n\n### DefaultScopes\n\n public static IReadOnlyList\u003cstring\u003e DefaultScopes { get; }\n\nThe default RankService scopes.\n\n**Remarks** \nThe default RankService scopes are:\n\n- \u003chttps://www.googleapis.com/auth/cloud-platform\u003e\n\n\u003cbr /\u003e\n\n### GrpcClient\n\n public virtual RankService.RankServiceClient GrpcClient { get; }\n\nThe underlying gRPC RankService client\n\n### LocationsClient\n\n public virtual LocationsClient LocationsClient { get; }\n\nThe [LocationsClient](https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Location/latest/Google.Cloud.Location.LocationsClient.html) associated with this client.\n\n### ServiceMetadata\n\n public static ServiceMetadata ServiceMetadata { get; }\n\nThe service metadata associated with this client type.\n\nMethods\n-------\n\n### Create()\n\n public static RankServiceClient Create()\n\nSynchronously creates a [RankServiceClient](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/latest/Google.Cloud.DiscoveryEngine.V1.RankServiceClient) using the default credentials, endpoint and\nsettings. To specify custom credentials or other settings, use [RankServiceClientBuilder](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/latest/Google.Cloud.DiscoveryEngine.V1.RankServiceClientBuilder).\n\n### CreateAsync(CancellationToken)\n\n public static Task\u003cRankServiceClient\u003e CreateAsync(CancellationToken cancellationToken = default)\n\nAsynchronously creates a [RankServiceClient](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/latest/Google.Cloud.DiscoveryEngine.V1.RankServiceClient) using the default credentials, endpoint and\nsettings. To specify custom credentials or other settings, use [RankServiceClientBuilder](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/latest/Google.Cloud.DiscoveryEngine.V1.RankServiceClientBuilder).\n\n### Rank(RankRequest, CallSettings)\n\n public virtual RankResponse Rank(RankRequest request, CallSettings callSettings = null)\n\nRanks a list of text records based on the given input query.\n\n**Example** \n\n // Create client\n RankServiceClient rankServiceClient = RankServiceClient.Create();\n // Initialize request argument(s)\n RankRequest request = new RankRequest\n {\n RankingConfigAsRankingConfigName = RankingConfigName.FromProjectLocationRankingConfig(\"[PROJECT]\", \"[LOCATION]\", \"[RANKING_CONFIG]\"),\n Model = \"\",\n TopN = 0,\n Query = \"\",\n Records =\n {\n new RankingRecord(),\n },\n IgnoreRecordDetailsInResponse = false,\n UserLabels = { { \"\", \"\" }, },\n };\n // Make the request\n RankResponse response = rankServiceClient.Rank(request);\n\n### RankAsync(RankRequest, CallSettings)\n\n public virtual Task\u003cRankResponse\u003e RankAsync(RankRequest request, CallSettings callSettings = null)\n\nRanks a list of text records based on the given input query.\n\n**Example** \n\n // Create client\n RankServiceClient rankServiceClient = await RankServiceClient.CreateAsync();\n // Initialize request argument(s)\n RankRequest request = new RankRequest\n {\n RankingConfigAsRankingConfigName = RankingConfigName.FromProjectLocationRankingConfig(\"[PROJECT]\", \"[LOCATION]\", \"[RANKING_CONFIG]\"),\n Model = \"\",\n TopN = 0,\n Query = \"\",\n Records =\n {\n new RankingRecord(),\n },\n IgnoreRecordDetailsInResponse = false,\n UserLabels = { { \"\", \"\" }, },\n };\n // Make the request\n RankResponse response = await rankServiceClient.RankAsync(request);\n\n### RankAsync(RankRequest, CancellationToken)\n\n public virtual Task\u003cRankResponse\u003e RankAsync(RankRequest request, CancellationToken cancellationToken)\n\nRanks a list of text records based on the given input query.\n\n**Example** \n\n // Create client\n RankServiceClient rankServiceClient = await RankServiceClient.CreateAsync();\n // Initialize request argument(s)\n RankRequest request = new RankRequest\n {\n RankingConfigAsRankingConfigName = RankingConfigName.FromProjectLocationRankingConfig(\"[PROJECT]\", \"[LOCATION]\", \"[RANKING_CONFIG]\"),\n Model = \"\",\n TopN = 0,\n Query = \"\",\n Records =\n {\n new RankingRecord(),\n },\n IgnoreRecordDetailsInResponse = false,\n UserLabels = { { \"\", \"\" }, },\n };\n // Make the request\n RankResponse response = await rankServiceClient.RankAsync(request);\n\n### ShutdownDefaultChannelsAsync()\n\n public static Task ShutdownDefaultChannelsAsync()\n\nShuts down any channels automatically created by [Create()](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/latest/Google.Cloud.DiscoveryEngine.V1.RankServiceClient#Google_Cloud_DiscoveryEngine_V1_RankServiceClient_Create) and\n[CreateAsync(CancellationToken)](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/latest/Google.Cloud.DiscoveryEngine.V1.RankServiceClient#Google_Cloud_DiscoveryEngine_V1_RankServiceClient_CreateAsync_System_Threading_CancellationToken_). Channels which weren't automatically created are not\naffected.\n\n**Remarks** \nAfter calling this method, further calls to [Create()](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/latest/Google.Cloud.DiscoveryEngine.V1.RankServiceClient#Google_Cloud_DiscoveryEngine_V1_RankServiceClient_Create) and\n[CreateAsync(CancellationToken)](/dotnet/docs/reference/Google.Cloud.DiscoveryEngine.V1/latest/Google.Cloud.DiscoveryEngine.V1.RankServiceClient#Google_Cloud_DiscoveryEngine_V1_RankServiceClient_CreateAsync_System_Threading_CancellationToken_) will create new channels, which could in turn be shut down\nby another call to this method."]]