Commands: StreamQueryAsync

StreamQueryAsync is used to Stream the query results to the client.

Syntax

Task<IAsyncEnumerator<FileHeader>> StreamQueryAsync(string query, string[] sortFields = null, int start = 0, int pageSize = int.MaxValue);
Parameters
query string The Lucene query
sortFields string[] The fields to sort by
start int The number of files that should be skipped
pageSize int The maximum number of file headers that will be retrieved

Return Value
Task<IAsyncEnumerator<FileHeader>> A task that represents the asynchronous operation. The task result is the enumerator of FileHeaders objects.

Example

using (var reader = await store.AsyncFilesCommands.StreamQueryAsync("Number:2", start: 10, pageSize: 20))
{
    while (await reader.MoveNextAsync())
    {
        allFilesMatchingCriteria.Add(reader.Current);
    }
}

By using the following code StreamQueryAsync can sort the result for the query:

var allFilesMatchingCriteria = new List<FileHeader>();
using (var reader = await store.AsyncFilesCommands.StreamQueryAsync("", sortFields: new string[] { "-__key" }))
{  
    while (await reader.MoveNextAsync())
    {
        allFilesMatchingCriteria.Add(reader.Current);
    }
}