KnowledgeBaseRetrievalClient Class

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

public final class KnowledgeBaseRetrievalClient

Initializes a new instance of the synchronous KnowledgeBaseRetrievalClient type.

Method Summary

Modifier and Type Method and Description
String getEndpoint()

Gets the endpoint used to communicate with the Azure AI Search service.

SearchServiceVersion getServiceVersion()

Gets the SearchServiceVersion used to communicate with the Azure AI Search service.

KnowledgeBaseRetrievalResult retrieve(KnowledgeBaseRetrievalOptions retrievalRequest)

KnowledgeBase retrieves relevant data from backing stores.

KnowledgeBaseRetrievalResult retrieve(KnowledgeBaseRetrievalOptions retrievalRequest, String querySourceAuthorization, String queryWorkIQSourceAuthorization)

KnowledgeBase retrieves relevant data from backing stores.

void retrieveStream(KnowledgeBaseRetrievalOptions retrievalRequest, ServerSentEventListener<KnowledgeBaseRetrievalStreamEvent> listener)

Retrieves relevant data from backing stores and streams progress and results as server-sent events.

void retrieveStream(KnowledgeBaseRetrievalOptions retrievalRequest, String querySourceAuthorization, String queryWorkIQSourceAuthorization, ServerSentEventListener<KnowledgeBaseRetrievalStreamEvent> listener)

Retrieves relevant data from backing stores and streams progress and results as server-sent events.

Response<KnowledgeBaseRetrievalResult> retrieveWithResponse(KnowledgeBaseRetrievalOptions retrievalRequest, RequestOptions requestOptions)

KnowledgeBase retrieves relevant data from backing stores.

Methods inherited from java.lang.Object

Method Details

getEndpoint

public String getEndpoint()

Gets the endpoint used to communicate with the Azure AI Search service.

Returns:

The endpoint.

getServiceVersion

public SearchServiceVersion getServiceVersion()

Gets the SearchServiceVersion used to communicate with the Azure AI Search service.

Returns:

The service version.

retrieve

public KnowledgeBaseRetrievalResult retrieve(KnowledgeBaseRetrievalOptions retrievalRequest)

KnowledgeBase retrieves relevant data from backing stores.

Parameters:

retrievalRequest - The retrieval request to process.

Returns:

the output contract for the retrieval response.

retrieve

public KnowledgeBaseRetrievalResult retrieve(KnowledgeBaseRetrievalOptions retrievalRequest, String querySourceAuthorization, String queryWorkIQSourceAuthorization)

KnowledgeBase retrieves relevant data from backing stores.

Parameters:

retrievalRequest - The retrieval request to process.
querySourceAuthorization - Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents.
queryWorkIQSourceAuthorization - User assertion token for a customer-owned Entra app registration configured on a Work IQ knowledge source. Used for on-behalf-of authentication to the Work IQ API.

Returns:

the output contract for the retrieval response.

retrieveStream

public void retrieveStream(KnowledgeBaseRetrievalOptions retrievalRequest, ServerSentEventListener<KnowledgeBaseRetrievalStreamEvent> listener)

Retrieves relevant data from backing stores and streams progress and results as server-sent events. If received, the terminal error or response.completed event is delivered before onClose() is invoked. End-of-stream without a terminal event closes normally. Transport and decoding failures are reported through onError(Throwable error). The client does not reconnect automatically.

Parameters:

retrievalRequest - The retrieval request to process.
listener - The listener that receives events and lifecycle notifications.

retrieveStream

public void retrieveStream(KnowledgeBaseRetrievalOptions retrievalRequest, String querySourceAuthorization, String queryWorkIQSourceAuthorization, ServerSentEventListener<KnowledgeBaseRetrievalStreamEvent> listener)

Retrieves relevant data from backing stores and streams progress and results as server-sent events. If received, the terminal error or response.completed event is delivered before onClose() is invoked. End-of-stream without a terminal event closes normally. Transport and decoding failures are reported through onError(Throwable error). The client does not reconnect automatically.

Parameters:

retrievalRequest - The retrieval request to process.
querySourceAuthorization - Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents.
queryWorkIQSourceAuthorization - User assertion token for a customer-owned Entra app registration configured on a Work IQ knowledge source. Used for on-behalf-of authentication to the Work IQ API.
listener - The listener that receives events and lifecycle notifications.

retrieveWithResponse

public Response<KnowledgeBaseRetrievalResult> retrieveWithResponse(KnowledgeBaseRetrievalOptions retrievalRequest, RequestOptions requestOptions)

KnowledgeBase retrieves relevant data from backing stores.

Header Parameters

| ------------------------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Name                            | Type   | Required | Description                                                                                                                         |
| x-ms-query-source-authorization | String | No       | Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents. |

You can add these to a request with RequestOptions#addHeader

Parameters:

retrievalRequest - The retrieval request to process.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the output contract for the retrieval response along with Response<T>.

Applies to