Language

SearchClient.GetDocument Method

Definition

Overloads

Name Description
GetDocument<T>(String, GetDocumentOptions, CancellationToken)

Retrieves a document from Azure AI Search. This is useful when a user clicks on a specific search result, and you want to look up specific details about that document. You can only get one document at a time. Use Search to get multiple documents in a single request. Lookup Document

GetDocument<T>(String, String, Nullable<Boolean>, GetDocumentOptions, CancellationToken)

Retrieves a specific document from the search index, with support for document-level security via querySourceAuthorization. Lookup Document

GetDocument<T>(String, GetDocumentOptions, CancellationToken)

Source:
SearchClient.cs
Source:
SearchClient.cs

Retrieves a document from Azure AI Search. This is useful when a user clicks on a specific search result, and you want to look up specific details about that document. You can only get one document at a time. Use Search to get multiple documents in a single request. Lookup Document

public virtual Azure.Response<T> GetDocument<T>(string key, Azure.Search.Documents.GetDocumentOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetDocument : string * Azure.Search.Documents.GetDocumentOptions * System.Threading.CancellationToken -> Azure.Response<'T>
override this.GetDocument : string * Azure.Search.Documents.GetDocumentOptions * System.Threading.CancellationToken -> Azure.Response<'T>
Public Overridable Function GetDocument(Of T) (key As String, Optional options As GetDocumentOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of T)

Type Parameters

T

The .NET type that maps to the index schema. Instances of this type can be retrieved as documents from the index.

Parameters

key
String

Required. An string value that uniquely identifies each document in the index. The key is sometimes referred to as a document ID. See Naming rules for the rules for constructing valid document keys.

options
GetDocumentOptions

Options to customize the operation's behavior.

cancellationToken
CancellationToken

Optional CancellationToken to propagate notifications that the operation should be canceled.

Returns

The document corresponding to the key.

Exceptions

Thrown when a failure is returned by the Search Service.

Remarks

The generic overloads of the GetDocument<T>(String, GetDocumentOptions, CancellationToken) and GetDocumentAsync<T>(String, GetDocumentOptions, CancellationToken) methods support mapping of Azure Search field types to .NET types via the type parameter T. Note that all search field types except collections are nullable, so we recommend using nullable types for the properties of T. See GetDocumentAsync<T>(String, GetDocumentOptions, CancellationToken) for more information.

Applies to

GetDocument<T>(String, String, Nullable<Boolean>, GetDocumentOptions, CancellationToken)

Source:
SearchClient.cs

Retrieves a specific document from the search index, with support for document-level security via querySourceAuthorization. Lookup Document

public virtual Azure.Response<T> GetDocument<T>(string key, string querySourceAuthorization, bool? enableElevatedRead = default, Azure.Search.Documents.GetDocumentOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetDocument : string * string * Nullable<bool> * Azure.Search.Documents.GetDocumentOptions * System.Threading.CancellationToken -> Azure.Response<'T>
override this.GetDocument : string * string * Nullable<bool> * Azure.Search.Documents.GetDocumentOptions * System.Threading.CancellationToken -> Azure.Response<'T>
Public Overridable Function GetDocument(Of T) (key As String, querySourceAuthorization As String, Optional enableElevatedRead As Nullable(Of Boolean) = Nothing, Optional options As GetDocumentOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of T)

Type Parameters

T

The .NET type that maps to the index schema. Instances of this type can be retrieved as documents from the index.

Parameters

key
String

The key of the document to retrieve.

querySourceAuthorization
String

Token identifying the user for whom the query is being executed. This token is used to enforce document-level security restrictions.

enableElevatedRead
Nullable<Boolean>

A value that enables elevated read access that bypasses document-level permission checks for the query operation.

options
GetDocumentOptions

Options to customize the operation's behavior.

cancellationToken
CancellationToken

Optional CancellationToken to propagate notifications that the operation should be canceled.

Returns

The document corresponding to the key as a T.

Exceptions

Thrown when a failure is returned by the Search Service.

Remarks

The generic overloads of the GetDocument<T>(String, String, Nullable<Boolean>, GetDocumentOptions, CancellationToken) and GetDocumentAsync<T>(String, String, Nullable<Boolean>, GetDocumentOptions, CancellationToken) methods support mapping of Azure Search field types to .NET types via the type parameter T. Note that all search field types except collections are nullable, so we recommend using nullable types for the properties of T. See GetDocumentAsync<T>(String, String, Nullable<Boolean>, GetDocumentOptions, CancellationToken) for more information.

Applies to