SearchClient.GetDocument Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| GetDocument(String, String, Nullable<Boolean>, IEnumerable<String>, RequestContext) |
[Protocol Method] Retrieves a document from the index.
|
| 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 |
GetDocument(String, String, Nullable<Boolean>, IEnumerable<String>, RequestContext)
- Source:
- SearchClient.cs
[Protocol Method] Retrieves a document from the index.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual Azure.Response GetDocument(string key, string querySourceAuthorization = default, bool? enableElevatedRead = default, System.Collections.Generic.IEnumerable<string> selectedFields = default, Azure.RequestContext context = default);
abstract member GetDocument : string * string * Nullable<bool> * seq<string> * Azure.RequestContext -> Azure.Response
override this.GetDocument : string * string * Nullable<bool> * seq<string> * Azure.RequestContext -> Azure.Response
Public Overridable Function GetDocument (key As String, Optional querySourceAuthorization As String = Nothing, Optional enableElevatedRead As Nullable(Of Boolean) = Nothing, Optional selectedFields As IEnumerable(Of String) = Nothing, Optional context As RequestContext = Nothing) As Response
Parameters
- key
- String
The key of the document to retrieve.
- querySourceAuthorization
- String
Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents.
A value that enables elevated read that bypass document level permission checks for the query operation.
- selectedFields
- IEnumerable<String>
List of field names to retrieve for the document; Any field not retrieved will be missing from the returned document.
- context
- RequestContext
The request options, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
key is null.
key is an empty string, and was expected to be non-empty.
Service returned a non-success status code.
Applies to
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.
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.