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

SearchClient.GetDocument<T> 方法

定义

从Azure 认知搜索检索文档。 当用户单击特定搜索结果并且希望查找关于该文档的特定详细信息时,这很有用。 一次只能获取一个文档。 使用搜索在单个请求中获取多个文档。 查找文档

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)

类型参数

T

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

参数

key
String

必需。 唯一标识索引中的每个文档的字符串值。 该密钥有时称为文档 ID。 有关构造有效文档键的规则,请参阅 命名 规则。

options
GetDocumentOptions

用于自定义操作行为的选项。

cancellationToken
CancellationToken

可选 CancellationToken ,用于传播应取消操作的通知。

返回

对应于 key的文档。

例外

搜索服务返回失败时引发。

注解

GetDocumentAsync<T>(String, GetDocumentOptions, CancellationToken) 方法的GetDocument<T>(String, GetDocumentOptions, CancellationToken)泛型重载支持通过类型参数 T将 Azure 搜索字段类型映射到 .NET 类型。 请注意,除集合之外的所有搜索字段类型都是可以为 null 的,因此我们建议对 的属性使用可为 null 的类型 T。 有关详细信息,请参阅GetDocumentAsync<T>(String, GetDocumentOptions, CancellationToken)

适用于