Discovery.Query Method

Definition

Overloads

Query(QueryConfig, CancellationToken)

Get data using search.

Query(RequestContent, RequestContext)

[Protocol Method] Get data using search.

Query(QueryConfig, CancellationToken)

Source:
Discovery.cs

Get data using search.

public virtual Azure.Response<Azure.Analytics.Purview.DataMap.QueryResult> Query (Azure.Analytics.Purview.DataMap.QueryConfig queryConfig, System.Threading.CancellationToken cancellationToken = default);
abstract member Query : Azure.Analytics.Purview.DataMap.QueryConfig * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Purview.DataMap.QueryResult>
override this.Query : Azure.Analytics.Purview.DataMap.QueryConfig * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Purview.DataMap.QueryResult>
Public Overridable Function Query (queryConfig As QueryConfig, Optional cancellationToken As CancellationToken = Nothing) As Response(Of QueryResult)

Parameters

queryConfig
QueryConfig

The search query of advanced search request.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

queryConfig is null.

Examples

This sample shows how to call Query.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Discovery client = new DataMapClient(endpoint, credential).GetDiscoveryClient(apiVersion: "2023-09-01");

QueryConfig queryConfig = new QueryConfig();
Response<QueryResult> response = client.Query(queryConfig);

This sample shows how to call Query 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");

QueryConfig queryConfig = new QueryConfig
{
    Keywords = "<keywords>",
    Limit = 1234,
    ContinuationToken = "<continuationToken>",
    Orderby = { BinaryData.FromObjectAsJson(new object()) },
    Filter = BinaryData.FromObjectAsJson(new object()),
    Facets = {new SearchFacetItem
    {
        Count = 1234,
        Facet = "<facet>",
        Sort = new SearchFacetSort
        {
            Count = SearchSortOrder.Ascend,
            Value = SearchSortOrder.Ascend,
        },
    }},
    TaxonomySetting = new SearchTaxonomySetting
    {
        AssetTypes = { "<assetTypes>" },
        Facet = default,
    },
};
Response<QueryResult> response = client.Query(queryConfig);

Applies to

Query(RequestContent, RequestContext)

Source:
Discovery.cs

[Protocol Method] Get data using search.

public virtual Azure.Response Query (Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member Query : Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.Query : Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function Query (content As RequestContent, Optional context As RequestContext = Nothing) As 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 Query 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 = client.Query(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());

This sample shows how to call Query 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,
    continuationToken = "<continuationToken>",
    orderby = new object[]
    {
        new object()
    },
    filter = new object(),
    facets = new object[]
    {
        new
        {
            count = 1234,
            facet = "<facet>",
            sort = new
            {
                count = "asc",
                value = "asc",
            },
        }
    },
    taxonomySetting = new
    {
        assetTypes = new object[]
        {
            "<assetTypes>"
        },
    },
});
Response response = client.Query(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("@search.count").ToString());
Console.WriteLine(result.GetProperty("@search.count.approximate").ToString());
Console.WriteLine(result.GetProperty("continuationToken").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("entityType")[0].GetProperty("count").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("entityType")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("assetType")[0].GetProperty("count").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("assetType")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("classification")[0].GetProperty("count").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("classification")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("term")[0].GetProperty("count").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("term")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("contactId")[0].GetProperty("count").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("contactId")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("contactType")[0].GetProperty("count").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("contactType")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("label")[0].GetProperty("count").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("label")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("glossaryType")[0].GetProperty("count").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("glossaryType")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("termStatus")[0].GetProperty("count").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("termStatus")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("termTemplate")[0].GetProperty("count").ToString());
Console.WriteLine(result.GetProperty("@search.facets").GetProperty("termTemplate")[0].GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("@search.score").ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("@search.highlights").GetProperty("id")[0].ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("@search.highlights").GetProperty("qualifiedName")[0].ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("@search.highlights").GetProperty("name")[0].ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("@search.highlights").GetProperty("description")[0].ToString());
Console.WriteLine(result.GetProperty("value")[0].GetProperty("@search.highlights").GetProperty("entityType")[0].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