IDocumentOperations.GetAsync Method (String, IEnumerable, CancellationToken)

Retrieves a document from the Azure Search index. (see https://msdn.microsoft.com/en-us/library/azure/dn798929.aspx for more information)

Namespace: Microsoft.Azure.Search
Assembly: Microsoft.Azure.Search (in Microsoft.Azure.Search.dll)

Usage

'Usage
Dim instance As IDocumentOperations
Dim key As String
Dim selectedFields As IEnumerable(Of String)
Dim cancellationToken As CancellationToken
Dim returnValue As Task(Of DocumentGetResponse(Of T))

returnValue = instance.GetAsync(key, selectedFields, cancellationToken)

Syntax

'Declaration
Function GetAsync(Of T) ( _
    key As String, _
    selectedFields As IEnumerable(Of String), _
    cancellationToken As CancellationToken _
) As Task(Of DocumentGetResponse(Of T))
Task<DocumentGetResponse<T>> GetAsync<T> (
    string key,
    IEnumerable<string> selectedFields,
    CancellationToken cancellationToken
)
generic<typename T>
Task<DocumentGetResponse<T>^>^ GetAsync (
    String^ key, 
    IEnumerable<String^>^ selectedFields, 
    CancellationToken cancellationToken
)

GenericParameters

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

Parameters

  • selectedFields
    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.
  • cancellationToken
    Cancellation token.

Return Value

Response containing the document.

Remarks

The generic overloads of the Get and GetAsync methods support mapping of Azure Search field types to .NET types via the type parameter T. Note that most Azure Search field types are nullable, so for primitives they often map to nullable types. The type mapping is as follows:

[list type="bullet"] [listheader] [term]Azure Search field type[/term] [description].NET type[/description] [/listheader] [item] [term]Edm.String[/term] [description]System.String (string in C#)[/description] [/item] [item] [term]Collection(Edm.String)[/term] [description]IEnumerable&amp;amp;lt;System.String&amp;amp;gt;[/description] [/item] [item] [term]Edm.Boolean[/term] [description]System.Nullable&amp;amp;lt;System.Boolean&amp;amp;gt; (bool? in C#)[/description] [/item] [item] [term]Edm.Double[/term] [description]System.Nullable&amp;amp;lt;System.Double&amp;amp;gt; (double? in C#)[/description] [/item] [item] [term]Edm.Int32[/term] [description]System.Nullable&amp;amp;lt;System.Int32&amp;amp;gt; (int? in C#)[/description] [/item] [item] [term]Edm.Int64[/term] [description]System.Nullable&amp;amp;lt;System.Int64&amp;amp;gt; (long? in C#)[/description] [/item] [item] [term]Edm.DateTimeOffset[/term] [description] System.Nullable&amp;amp;lt;System.DateTimeOffset&amp;amp;gt; (DateTimeOffset? in C#) or System.Nullable&amp;amp;lt;System.DateTime&amp;amp;gt; (DateTime? in C#). 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: [list type="bullet"][item][term]UTC DateTime[/term][description]Sent as-is to the index.[/description][/item][item][term]Local DateTime[/term][description]Converted to UTC before being sent to the index.[/description][/item][item][term]DateTime with unspecified time zone[/term][description]Assumed to be UTC and sent as-is to the index.[/description][/item][/list][/description] [/item] [item] [term]Edm.GeographyPoint[/term] [description] [c cref="T:Microsoft.Spatial.GeographyPoint"]Microsoft.Spatial.GeographyPoint[/c] [/description] [/item] [/list]

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Target Platforms

See Also

Reference

IDocumentOperations Interface
IDocumentOperations Members
Microsoft.Azure.Search Namespace