Share via


SearchKnowledgeBaseClientBuilder Class

  • java.lang.Object
    • com.azure.search.documents.knowledgebases.SearchKnowledgeBaseClientBuilder

Implements

public final class SearchKnowledgeBaseClientBuilder
implements AzureKeyCredentialTrait<SearchKnowledgeBaseClientBuilder>, ConfigurationTrait<SearchKnowledgeBaseClientBuilder>, EndpointTrait<SearchKnowledgeBaseClientBuilder>, HttpTrait<SearchKnowledgeBaseClientBuilder>, TokenCredentialTrait<SearchKnowledgeBaseClientBuilder>

This class provides a fluent builder API to help configure and instantiate SearchKnowledgeBaseClient and SearchKnowledgeBaseAsyncClient for interacting with Azure AI Search Knowledge Agents.

Overview

This builder enables the creation of both synchronous and asynchronous clients for Azure AI Search Knowledge Agents, allowing you to interact with knowledge retrieval and knowledgeBase-based search capabilities. The builder supports configuration of authentication, endpoint, knowledgeBase name, API version, and HTTP pipeline options, following Azure SDK for Java standards.

Getting Started

To create a client, configure the required properties such as the service endpoint, knowledgeBase name, API version, and authentication credentials. The builder supports both API key and Microsoft Entra ID (role-based) authentication. Additional options such as custom HTTP pipeline policies, retry options, logging, and serialization can also be configured.

Authentication

Azure AI Search Knowledge Agents support authentication using either an AzureKeyCredential (API key) or a TokenCredential (Microsoft Entra ID). When using Microsoft Entra ID, you may also specify a SearchAudience to target a specific Azure cloud environment.

Client Instantiation

Use buildClient() to create a synchronous SearchKnowledgeBaseClient, or buildAsyncClient() to create an asynchronous SearchKnowledgeBaseAsyncClient. Each call to these methods returns a new client instance with the configured options.

Thread Safety

Client instances created by this builder are thread-safe and intended to be shared and reused across threads. The builder itself is not thread-safe and should not be used concurrently from multiple threads.

Additional Information

  • For more information about Azure AI Search Knowledge Agents, see the Azure documentation.
  • For authentication details, see the Azure AI Search security documentation.
  • For Azure SDK for Java guidelines, see the Azure SDK for Java Introduction.

Constructor Summary

Constructor Description
SearchKnowledgeBaseClientBuilder()

Creates a new builder instance.

Method Summary

Modifier and Type Method and Description
SearchKnowledgeBaseClientBuilder addPolicy(HttpPipelinePolicy policy)
SearchKnowledgeBaseClientBuilder audience(SearchAudience audience)

Sets the audience for the Azure AI Search instance.

SearchKnowledgeBaseAsyncClient buildAsyncClient()

Builds an asynchronous SearchKnowledgeBaseAsyncClient.

SearchKnowledgeBaseClient buildClient()

Builds a synchronous SearchKnowledgeBaseClient.

SearchKnowledgeBaseClientBuilder clientOptions(ClientOptions clientOptions)
SearchKnowledgeBaseClientBuilder configuration(Configuration configuration)
SearchKnowledgeBaseClientBuilder credential(AzureKeyCredential credential)
SearchKnowledgeBaseClientBuilder credential(TokenCredential credential)
SearchKnowledgeBaseClientBuilder endpoint(String endpoint)

Sets the service endpoint for the Azure AI Search instance.

SearchKnowledgeBaseClientBuilder httpClient(HttpClient client)
SearchKnowledgeBaseClientBuilder httpLogOptions(HttpLogOptions logOptions)
SearchKnowledgeBaseClientBuilder knowledgeBaseName(String knowledgeBaseName)

Sets the knowledgeBase name for the Azure AI Search knowledgeBase.

SearchKnowledgeBaseClientBuilder pipeline(HttpPipeline httpPipeline)
SearchKnowledgeBaseClientBuilder retryOptions(RetryOptions retryOptions)
SearchKnowledgeBaseClientBuilder serviceVersion(SearchServiceVersion apiVersion)

Sets the API version to use for requests.

Methods inherited from java.lang.Object

Constructor Details

SearchKnowledgeBaseClientBuilder

public SearchKnowledgeBaseClientBuilder()

Creates a new builder instance.

Method Details

addPolicy

public SearchKnowledgeBaseClientBuilder addPolicy(HttpPipelinePolicy policy)

Parameters:

policy

audience

public SearchKnowledgeBaseClientBuilder audience(SearchAudience audience)

Sets the audience for the Azure AI Search instance.

Parameters:

audience - The audience to use.

Returns:

The updated builder object.

buildAsyncClient

public SearchKnowledgeBaseAsyncClient buildAsyncClient()

Builds an asynchronous SearchKnowledgeBaseAsyncClient.

Returns:

buildClient

public SearchKnowledgeBaseClient buildClient()

Builds a synchronous SearchKnowledgeBaseClient.

Returns:

clientOptions

public SearchKnowledgeBaseClientBuilder clientOptions(ClientOptions clientOptions)

Parameters:

clientOptions

configuration

public SearchKnowledgeBaseClientBuilder configuration(Configuration configuration)

Parameters:

configuration

credential

public SearchKnowledgeBaseClientBuilder credential(AzureKeyCredential credential)

Parameters:

credential

credential

public SearchKnowledgeBaseClientBuilder credential(TokenCredential credential)

Parameters:

credential

endpoint

public SearchKnowledgeBaseClientBuilder endpoint(String endpoint)

Sets the service endpoint for the Azure AI Search instance.

Parameters:

endpoint - The URL of the Azure AI Search instance.

Returns:

The updated builder object.

httpClient

public SearchKnowledgeBaseClientBuilder httpClient(HttpClient client)

Parameters:

client

httpLogOptions

public SearchKnowledgeBaseClientBuilder httpLogOptions(HttpLogOptions logOptions)

Parameters:

logOptions

knowledgeBaseName

public SearchKnowledgeBaseClientBuilder knowledgeBaseName(String knowledgeBaseName)

Sets the knowledgeBase name for the Azure AI Search knowledgeBase.

Parameters:

knowledgeBaseName - The name of the knowledgeBase.

Returns:

The updated builder object.

pipeline

public SearchKnowledgeBaseClientBuilder pipeline(HttpPipeline httpPipeline)

Parameters:

httpPipeline

retryOptions

public SearchKnowledgeBaseClientBuilder retryOptions(RetryOptions retryOptions)

Parameters:

retryOptions

serviceVersion

public SearchKnowledgeBaseClientBuilder serviceVersion(SearchServiceVersion apiVersion)

Sets the API version to use for requests.

Parameters:

apiVersion - The API version.

Returns:

The updated builder object.

Applies to