IFulltext QueryTDocumentTo Future List Async(Cancellation Token) Method
Get an asynchronously, lazily initialized list of results. Accessing the results will trigger the execution of all pending future results as a batch of asynchronous queries in
a single roundtrip to searchd.
Definition
Namespace: SphinxConnector.FluentApi
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.1.0
A lazily initialized list of results for the query.
A task representing the asynchronous operation.
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.1.0
C#
Lazy<Task<IList<TDocument>>> ToFutureListAsync(
CancellationToken cancellationToken
)VB
Function ToFutureListAsync (
cancellationToken As CancellationToken
) As Lazy(Of Task(Of IList(Of TDocument)))Parameters
- cancellationToken CancellationToken
- The token to monitor for cancellation requests.
Return Value
LazyTaskIListTDocumentA lazily initialized list of results for the query.
A task representing the asynchronous operation.
Example
Suppose you have the following class representing a document in your index:
Consider the following example:
C#
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public decimal Price { get; set; }
public int CategoryId { get; set; }
public int VendorId { get; set; }
public int Weight { get; set; }
}
Consider the following example:
C#
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
var results = fulltextSession.Query<Product>().
Match("a product").
ToFutureListAsync();
var facets = fulltextSession.Query<Product>().
Match("a product").
GroupBy(p => p.CategoryId).
Select(p => new
{
p.CategoryId,
Count = Projection.Count()
}).
ToFutureListAsync();
//No query has been executed up to this point
foreach (result in await results.Value) //<-- accessing the result of a query will cause all pending future queries
{ //to be executed in one roundtrip to Sphinx at this point
//...
}
}Exceptions
| FulltextException | Occurs when there is an error during the execution of the query. |
| OperationCanceledException | Occurs when cancellation has been requested. |