你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

IDocumentsOperations.GetWithHttpMessagesAsync 方法

定义

重载

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

从搜索索引中检索文档。 https://docs.microsoft.com/rest/api/searchservice/Lookup-Document

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

从搜索索引中检索文档。 https://docs.microsoft.com/rest/api/searchservice/Lookup-Document

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

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))

参数

key
String

要检索的文档的键;有关构造有效文档键的规则,请参阅 https://docs.microsoft.com/rest/api/searchservice/Naming-rules

selectedFields
IEnumerable<String>

要为文档检索的字段名称列表;返回的文档中将缺少任何未检索到的字段。

searchRequestOptions
SearchRequestOptions

操作的其他参数

customHeaders
Dictionary<String,List<String>>

将添加到请求的标头。

cancellationToken
CancellationToken

取消标记。

返回

包含文档的响应。

注解

Get、GetAsync 和 GetWithHttpMessagesAsync 方法的非泛型重载会尽力尝试将响应有效负载中的 JSON 类型映射到 .NET 类型。 此映射没有索引中精确类型信息的好处,因此映射并不总是正确的。 具体而言,请注意以下情况:

  • 任何没有小数点的数值都将反序列化为 System.Int64 (C# 中的长,int64 在 F#) 。
  • 特殊的双精度浮点值(如 NaN 和 Infinity)将反序列化为类型 System.String 而不是 System.Double,即使它们位于具有常规浮点值的数组中。
  • 任何值格式类似于 DateTimeOffset 的字符串字段都会被错误地反序列化。 这也适用于字符串数组中的此类值。 建议将此类值存储在 Edm.DateTimeOffset 字段中,而不是 Edm.String 字段中。
  • 任何 Edm.DateTimeOffset 字段都将反序列化为 System.DateTimeOffset,而不是 System.DateTime。
  • 任何空 JSON 数组都将反序列化为 C# 中的 System.Object (object[] 数组,在 F# ) 中为 obj[]。
  • 基元类型的任何数组都将反序列化为其相应 .NET 类型的数组,而不是 System.Object 的数组,除非值不能全部反序列化为同一类型。 例如,数组 [3.14, “NaN”] 和 [“hello”, “2016-10-10T17:41:05.123-07:00”] 都将反序列化为 C# 中的 System.Object (object[] 的数组,在 F#) 中为 obj[]。 这是因为特殊的双精度值始终反序列化为字符串,而类似于 DateTimeOffset 的字符串始终反序列化为 DateTimeOffset。
  • 复杂字段将以递归方式反序列化为 类型的 Document实例。 同样,复杂集合字段将反序列化为此类实例的数组。

适用于

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

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))

类型参数

T

映射到索引架构的 CLR 类型。 可以从索引中以文档的形式检索此类型的实例。

参数

key
String

要检索的文档的键;有关构造有效文档键的规则,请参阅 https://docs.microsoft.com/rest/api/searchservice/Naming-rules

selectedFields
IEnumerable<String>

要为文档检索的字段名称列表;任何未检索到的字段都将具有 null 或 default 作为返回的对象中的相应属性值。

searchRequestOptions
SearchRequestOptions

操作的其他参数

customHeaders
Dictionary<String,List<String>>

将添加到请求的标头。

cancellationToken
CancellationToken

取消标记。

返回

包含文档的响应。

注解

Get、GetAsync 和 GetWithHttpMessagesAsync 方法的泛型重载支持通过类型参数 T 将 Azure 搜索字段类型映射到 .NET 类型。请注意,除集合之外的所有搜索字段类型都可以为 null,因此建议对 T 的属性使用可为 null 的类型。类型映射如下所示:

搜索字段类型.NET 类型
Edm.StringC# 和 F# ) 中的 System.String (字符串
Edm.BooleanC# 中的 System.Nullable<System.Boolean> (bool?,<>F#)
Edm.DoubleC# 中的 System.Nullable<System.Double> (double?,<>F#)
Edm.Int32C# 中的 System.Nullable<System.Int32> (int?,<>F#)
Edm.Int64C# 中的 System.Nullable<System.Int64> (long?,<>F#)
Edm.DateTimeOffset C# 中的 System.Nullable System.DateTimeOffset> (DateTimeOffset?、F#) 中的可为 Null DateTimeOffset<> 或 C# 中的 System.Nullable<System.DateTime> (DateTime?,F#) 中的 Nullable<DateTime>。< 虽然我们建议使用 DateTimeOffset,但这两种类型都起作用。 检索文档时,DateTime 值将始终采用 UTC 格式。 为文档编制索引时,DateTime 值的解释如下:
UTC DateTime按原样发送到索引。
本地日期/时间在发送到索引之前已转换为 UTC。
具有未指定时区的 DateTime假定为 UTC,并按原样发送到索引。
Edm.GeographyPointMicrosoft.Spatial.GeographyPoint
Edm.ComplexType 可从复杂字段中的 JSON 对象反序列化的任何类型。 这可以是值类型或引用类型,但我们建议使用引用类型,因为复杂字段在Azure 认知搜索中可为 null。
集合 (Edm.String)F#) 中的 IEnumerable<System.String> (seq<字符串>
集合 (Edm.Boolean) F#) 中的 IEnumerable<System.Boolean> (seq<bool>
集合 (Edm.Double) F#) 中的 IEnumerable<System.Double> (seq<float>
集合 (Edm.Int32) F#) 中的 IEnumerable<System.Int32> (seq<int>
Collection (Edm.Int64) F#) 中的 IEnumerable<System.Int64> (seq<int64>
集合 (Edm.DateTimeOffset) F#) 中的 IEnumerable<System.DateTimeOffset> 或 IEnumerable<System.DateTime> (seq<DateTimeOffset> 或 seq<DateTime> 。 虽然我们建议使用 IEnumerable<System.DateTimeOffset>,但这两种类型都起作用。 有关详细信息,请参阅上述 Edm.DateTimeOffset 上的说明。
集合 (Edm.GeographyPoint) IEnumerable<Microsoft.Spatial.GeographyPoint> (seq<GeographyPoint> in F#)
集合 (Edm.ComplexType) F#) 中的 IEnumerable<U> (seq<U> ,其中 U 是可从复杂集合字段中的 JSON 对象反序列化的任何类型。 这可以是值类型或引用类型。

适用于