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)

Retrieves relevant data from backing stores.

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

KnowledgeBase retrieves relevant data from backing stores.

CloseableIterableStream<KnowledgeBaseRetrievalStreamEvent> retrieveStream(KnowledgeBaseRetrievalOptions retrievalRequest)

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

CloseableIterableStream<KnowledgeBaseRetrievalStreamEvent> retrieveStream(KnowledgeBaseRetrievalOptions retrievalRequest, String querySourceAuthorization)

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

CloseableIterableStream<KnowledgeBaseRetrievalStreamEvent> retrieveStream(KnowledgeBaseRetrievalOptions retrievalRequest, String querySourceAuthorization, String queryWorkIQSourceAuthorization)

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. If its getQuerySourceAuthorization() is set, it is sent only as the x-ms-query-source-authorization header and is never serialized into the request body.

Returns:

the output contract for the retrieval response.

retrieve

public KnowledgeBaseRetrievalResult retrieve(KnowledgeBaseRetrievalOptions retrievalRequest, String querySourceAuthorization)

Retrieves relevant data from backing stores.

Parameters:

retrievalRequest - The retrieval request to process. If its getQuerySourceAuthorization() is set, it is sent only as the x-ms-query-source-authorization header and is never serialized into the request body.
querySourceAuthorization - Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents. A non-null value overrides getQuerySourceAuthorization(); null falls back to it, and an empty string is treated as an explicit value.

Returns:

The retrieval result.

retrieve

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

KnowledgeBase retrieves relevant data from backing stores.

Parameters:

retrievalRequest - The retrieval request to process. If its getQuerySourceAuthorization() is set, it is sent only as the x-ms-query-source-authorization header and is never serialized into the request body.
querySourceAuthorization - Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents. A non-null value overrides getQuerySourceAuthorization(); null falls back to it, and an empty string is treated as an explicit value.
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 CloseableIterableStream<KnowledgeBaseRetrievalStreamEvent> retrieveStream(KnowledgeBaseRetrievalOptions retrievalRequest)

Retrieves relevant data from backing stores and streams progress and results as server-sent events. Events are polymorphic: see KnowledgeBaseRetrievalStreamEvent for the known subtypes. Use a known subtype's getValue() to access its typed payload, for example getValue(). Unrecognized events expose only their names through getEventName(); their payloads are not available. Events are decoded lazily by a single iterator. Use try-with-resources to close the stream when iteration ends early. The response is also closed on end-of-stream, a terminal event, or an iteration failure. Closing the stream is idempotent and may throw IOException. If received, the terminal error or response.completed event is emitted before iteration ends. A failure while closing after a terminal event is reported by the next iterator access or explicit close, after the terminal event is delivered. End-of-stream without a terminal event completes normally. Transport and decoding failures are thrown during iteration. The client does not reconnect automatically.

Parameters:

retrievalRequest - The retrieval request to process. If its getQuerySourceAuthorization() is set, it is sent only as the x-ms-query-source-authorization header and is never serialized into the request body.

Returns:

A closeable stream of typed knowledge base retrieval events.

retrieveStream

public CloseableIterableStream<KnowledgeBaseRetrievalStreamEvent> retrieveStream(KnowledgeBaseRetrievalOptions retrievalRequest, String querySourceAuthorization)

Retrieves relevant data from backing stores and streams progress and results as server-sent events. Events are polymorphic: see KnowledgeBaseRetrievalStreamEvent for the known subtypes. Use a known subtype's getValue() to access its typed payload, for example getValue(). Unrecognized events expose only their names through getEventName(); their payloads are not available. Events are decoded lazily by a single iterator. Use try-with-resources to close the stream when iteration ends early. The response is also closed on end-of-stream, a terminal event, or an iteration failure. Closing the stream is idempotent and may throw IOException. If received, the terminal error or response.completed event is emitted before iteration ends. A failure while closing after a terminal event is reported by the next iterator access or explicit close, after the terminal event is delivered. End-of-stream without a terminal event completes normally. Transport and decoding failures are thrown during iteration. The client does not reconnect automatically.

Parameters:

retrievalRequest - The retrieval request to process. If its getQuerySourceAuthorization() is set, it is sent only as the x-ms-query-source-authorization header and is never serialized into the request body.
querySourceAuthorization - Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents. A non-null value overrides getQuerySourceAuthorization(); null falls back to it, and an empty string is treated as an explicit value.

Returns:

A closeable stream of typed knowledge base retrieval events.

retrieveStream

public CloseableIterableStream<KnowledgeBaseRetrievalStreamEvent> retrieveStream(KnowledgeBaseRetrievalOptions retrievalRequest, String querySourceAuthorization, String queryWorkIQSourceAuthorization)

Retrieves relevant data from backing stores and streams progress and results as server-sent events. Events are polymorphic: see KnowledgeBaseRetrievalStreamEvent for the known subtypes. Use a known subtype's getValue() to access its typed payload, for example getValue(). Unrecognized events expose only their names through getEventName(); their payloads are not available. Events are decoded lazily by a single iterator. Use try-with-resources to close the stream when iteration ends early. The response is also closed on end-of-stream, a terminal event, or an iteration failure. Closing the stream is idempotent and may throw IOException. If received, the terminal error or response.completed event is emitted before iteration ends. A failure while closing after a terminal event is reported by the next iterator access or explicit close, after the terminal event is delivered. End-of-stream without a terminal event completes normally. Transport and decoding failures are thrown during iteration. The client does not reconnect automatically.

Parameters:

retrievalRequest - The retrieval request to process. If its getQuerySourceAuthorization() is set, it is sent only as the x-ms-query-source-authorization header and is never serialized into the request body.
querySourceAuthorization - Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents. A non-null value overrides getQuerySourceAuthorization(); null falls back to it, and an empty string is treated as an explicit value.
queryWorkIQSourceAuthorization - User assertion token for a customer-owned Entra app registration configured on a Work IQ knowledge source.

Returns:

A closeable stream of typed knowledge base retrieval events.

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