Discovery.SuggestAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
SuggestAsync(SuggestConfig, CancellationToken) |
Get search suggestions by query criteria. |
SuggestAsync(RequestContent, RequestContext) |
[Protocol Method] Get search suggestions by query criteria.
|
SuggestAsync(SuggestConfig, CancellationToken)
- Source:
- Discovery.cs
Get search suggestions by query criteria.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.SuggestResult>> SuggestAsync (Azure.Analytics.Purview.DataMap.SuggestConfig suggestConfig, System.Threading.CancellationToken cancellationToken = default);
abstract member SuggestAsync : Azure.Analytics.Purview.DataMap.SuggestConfig * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.SuggestResult>>
override this.SuggestAsync : Azure.Analytics.Purview.DataMap.SuggestConfig * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.SuggestResult>>
Public Overridable Function SuggestAsync (suggestConfig As SuggestConfig, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of SuggestResult))
Parameters
- suggestConfig
- SuggestConfig
The payload of suggest request.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
suggestConfig
is null.
Examples
This sample shows how to call SuggestAsync.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Discovery client = new DataMapClient(endpoint, credential).GetDiscoveryClient(apiVersion: "2023-09-01");
SuggestConfig suggestConfig = new SuggestConfig();
Response<SuggestResult> response = await client.SuggestAsync(suggestConfig);
This sample shows how to call SuggestAsync with all parameters.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Discovery client = new DataMapClient(endpoint, credential).GetDiscoveryClient(apiVersion: "2023-09-01");
SuggestConfig suggestConfig = new SuggestConfig
{
Keywords = "<keywords>",
Limit = 1234,
Filter = BinaryData.FromObjectAsJson(new object()),
};
Response<SuggestResult> response = await client.SuggestAsync(suggestConfig);
Applies to
SuggestAsync(RequestContent, RequestContext)
- Source:
- Discovery.cs
[Protocol Method] Get search suggestions by query criteria.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler SuggestAsync(SuggestConfig, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> SuggestAsync (Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member SuggestAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.SuggestAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function SuggestAsync (content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- content
- RequestContent
The content to send as the body of the request.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
content
is null.
Service returned a non-success status code.
Examples
This sample shows how to call SuggestAsync and parse the result.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Discovery client = new DataMapClient(endpoint, credential).GetDiscoveryClient(apiVersion: "2023-09-01");
using RequestContent content = RequestContent.Create(new object());
Response response = await client.SuggestAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());
This sample shows how to call SuggestAsync with all request content and parse the result.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Discovery client = new DataMapClient(endpoint, credential).GetDiscoveryClient(apiVersion: "2023-09-01");
using RequestContent content = RequestContent.Create(new
{
keywords = "<keywords>",
limit = 1234,
filter = new object(),
});
Response response = await client.SuggestAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("value")[0].GetProperty("@search.score").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("@search.text").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("objectType").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("createTime").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("updateTime").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("qualifiedName").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("entityType").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("endorsement").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("owner").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("classification")[0].ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("label")[0].ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("term")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("term")[0].GetProperty("glossaryName").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("term")[0].GetProperty("guid").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("contact")[0].GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("contact")[0].GetProperty("info").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("contact")[0].GetProperty("contactType").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("assetType")[0].ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("glossaryType").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("glossary").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("termStatus").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("termTemplate")[0].ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("longDescription").ToString());
Applies to
Azure SDK for .NET