IDocumentsOperations.GetWithHttpMessagesAsync Method

Definition

Overloads

GetWithHttpMessagesAsync(String, IEnumerable<String>, SearchRequestOptions, Dictionary<String,List<String>>, CancellationToken)

Retrieves a document from the search index. https://docs.microsoft.com/rest/api/searchservice/Lookup-Document

GetWithHttpMessagesAsync<T>(String, IEnumerable<String>, SearchRequestOptions, Dictionary<String,List<String>>, CancellationToken)

Retrieves a document from the search index. https://docs.microsoft.com/rest/api/searchservice/Lookup-Document

GetWithHttpMessagesAsync(String, IEnumerable<String>, SearchRequestOptions, Dictionary<String,List<String>>, CancellationToken)

Retrieves a document from the search index. https://docs.microsoft.com/rest/api/searchservice/Lookup-Document

public System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<Microsoft.Azure.Search.Models.Document>> GetWithHttpMessagesAsync (string key, System.Collections.Generic.IEnumerable<string> selectedFields, Microsoft.Azure.Search.Models.SearchRequestOptions searchRequestOptions = default, System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>> customHeaders = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetWithHttpMessagesAsync : string * seq<string> * Microsoft.Azure.Search.Models.SearchRequestOptions * System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<Microsoft.Azure.Search.Models.Document>>
Public Function GetWithHttpMessagesAsync (key As String, selectedFields As IEnumerable(Of String), Optional searchRequestOptions As SearchRequestOptions = Nothing, Optional customHeaders As Dictionary(Of String, List(Of String)) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of AzureOperationResponse(Of Document))

Parameters

key
String

The key of the document to retrieve; See https://docs.microsoft.com/rest/api/searchservice/Naming-rules for the rules for constructing valid document keys.

selectedFields
IEnumerable<String>

List of field names to retrieve for the document; Any field not retrieved will be missing from the returned document.

searchRequestOptions
SearchRequestOptions

Additional parameters for the operation

customHeaders
Dictionary<String,List<String>>

The headers that will be added to request.

cancellationToken
CancellationToken

The cancellation token.

Returns

Response containing the document.

Remarks

The non-generic overloads of the Get, GetAsync, and GetWithHttpMessagesAsync methods make a best-effort attempt to map JSON types in the response payload to .NET types. This mapping does not have the benefit of precise type information from the index, so the mapping is not always correct. In particular, be aware of the following cases:

  • Any numeric value without a decimal point will be deserialized to System.Int64 (long in C#, int64 in F#).
  • Special double-precision floating point values such as NaN and Infinity will be deserialized as type System.String rather than System.Double, even if they are in arrays with regular floating point values.
  • Any string field with a value formatted like a DateTimeOffset will be deserialized incorrectly. This applies to such values in arrays of strings as well. We recommend storing such values in Edm.DateTimeOffset fields rather than Edm.String fields.
  • Any Edm.DateTimeOffset field will be deserialized as a System.DateTimeOffset, not System.DateTime.
  • Any empty JSON array will be deserialized as an array of System.Object (object[] in C#, obj[] in F#).
  • Any array of a primitive type will be deserialized as an array of its corresponding .NET type, not as an array of System.Object, unless the values cannot all be deserialized to the same type. For example, the arrays [3.14, "NaN"] and ["hello", "2016-10-10T17:41:05.123-07:00"] will both deserialize as arrays of System.Object (object[] in C#, obj[] in F#). This is because special double values always deserialize as strings, while strings that look like DateTimeOffset always deserialize as DateTimeOffset.
  • Complex fields will be recursively deserialized into instances of type Document. Similarly, complex collection fields will be deserialized into arrays of such instances.

Applies to

GetWithHttpMessagesAsync<T>(String, IEnumerable<String>, SearchRequestOptions, Dictionary<String,List<String>>, CancellationToken)

Retrieves a document from the search index. https://docs.microsoft.com/rest/api/searchservice/Lookup-Document

public System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<T>> GetWithHttpMessagesAsync<T> (string key, System.Collections.Generic.IEnumerable<string> selectedFields, Microsoft.Azure.Search.Models.SearchRequestOptions searchRequestOptions = default, System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>> customHeaders = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetWithHttpMessagesAsync : string * seq<string> * Microsoft.Azure.Search.Models.SearchRequestOptions * System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<'T>>
Public Function GetWithHttpMessagesAsync(Of T) (key As String, selectedFields As IEnumerable(Of String), Optional searchRequestOptions As SearchRequestOptions = Nothing, Optional customHeaders As Dictionary(Of String, List(Of String)) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of AzureOperationResponse(Of T))

Type Parameters

T

The CLR 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; See https://docs.microsoft.com/rest/api/searchservice/Naming-rules for the rules for constructing valid document keys.

selectedFields
IEnumerable<String>

List of field names to retrieve for the document; Any field not retrieved will have null or default as its corresponding property value in the returned object.

searchRequestOptions
SearchRequestOptions

Additional parameters for the operation

customHeaders
Dictionary<String,List<String>>

The headers that will be added to request.

cancellationToken
CancellationToken

The cancellation token.

Returns

Response containing the document.

Remarks

The generic overloads of the Get, GetAsync, and GetWithHttpMessagesAsync 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. The type mapping is as follows:

Search field type.NET type
Edm.StringSystem.String (string in C# and F#)
Edm.BooleanSystem.Nullable<System.Boolean> (bool? in C#, Nullable<bool> in F#)
Edm.DoubleSystem.Nullable<System.Double> (double? in C#, Nullable<float> in F#)
Edm.Int32System.Nullable<System.Int32> (int? in C#, Nullable<int> in F#)
Edm.Int64System.Nullable<System.Int64> (long? in C#, Nullable<int64> in F#)
Edm.DateTimeOffset System.Nullable<System.DateTimeOffset> (DateTimeOffset? in C#, Nullable<DateTimeOffset> in F#) or System.Nullable<System.DateTime> (DateTime? in C#, Nullable<DateTime> in F#). Both types work, although we recommend using DateTimeOffset. When retrieving documents, DateTime values will always be in UTC. When indexing documents, DateTime values are interpreted as follows:
UTC DateTimeSent as-is to the index.
Local DateTimeConverted to UTC before being sent to the index.
DateTime with unspecified time zoneAssumed to be UTC and sent as-is to the index.
Edm.GeographyPointMicrosoft.Spatial.GeographyPoint
Edm.ComplexType Any type that can be deserialized from the JSON objects in the complex field. This can be a value type or a reference type, but we recommend using a reference type since complex fields are nullable in Azure Cognitive Search.
Collection(Edm.String)IEnumerable<System.String> (seq<string> in F#)
Collection(Edm.Boolean)IEnumerable<System.Boolean> (seq<bool> in F#)
Collection(Edm.Double)IEnumerable<System.Double> (seq<float> in F#)
Collection(Edm.Int32)IEnumerable<System.Int32> (seq<int> in F#)
Collection(Edm.Int64)IEnumerable<System.Int64> (seq<int64> in F#)
Collection(Edm.DateTimeOffset) IEnumerable<System.DateTimeOffset> or IEnumerable<System.DateTime> (seq<DateTimeOffset> or seq<DateTime> in F#). Both types work, although we recommend using IEnumerable<System.DateTimeOffset>. See the notes above on Edm.DateTimeOffset for details.
Collection(Edm.GeographyPoint)IEnumerable<Microsoft.Spatial.GeographyPoint> (seq<GeographyPoint> in F#)
Collection(Edm.ComplexType) IEnumerable<U> (seq<U> in F#) where U is any type that can be deserialized from the JSON objects in the complex collection field. This can be a value type or a reference type.

Applies to