Class CollectionFindAndRerankCursor<T, TResult>
- Namespace
- DataStax.AstraDB.DataApi.Core.Enumeration
- Assembly
- DataStax.AstraDB.DataApi.dll
A cursor for running a find-and-rerank query on a collection with projection support. This class allows you to specify a different result type than the row type, useful for projections.
public class CollectionFindAndRerankCursor<T, TResult> : FindAndRerankCursor<T, TResult, CollectionFindAndRerankSortBuilder<T>, CollectionFindAndRerankCursor<T, TResult>>, IDisposable, IEnumerable<TResult>, IEnumerable, IAsyncEnumerable<TResult> where T : class where TResult : class
Type Parameters
TThe type of the rows in the table.
TResultThe type to deserialize the results to (e.g., when using projections).
- Inheritance
-
AbstractCursor<TResult>PaginatedCursor<T, TResult, BaseFindAndRerankOptions<T, CollectionFindAndRerankSortBuilder<T>>, CollectionFindAndRerankCursor<T, TResult>>FindAndRerankCursor<T, TResult, CollectionFindAndRerankSortBuilder<T>, CollectionFindAndRerankCursor<T, TResult>>CollectionFindAndRerankCursor<T, TResult>
- Implements
-
IEnumerable<TResult>IAsyncEnumerable<TResult>
- Derived
- Inherited Members
Examples
// Using projection to return only specific fields
public class MyDocumentProjection
{
public string Name { get; set; }
public string Email { get; set; }
}
var cursor = collection.FindAndRerank<MyDocumentProjection>()
.Sort(
Builders<MyDocument>.CollectionFindAndRerankSort.Hybrid(
"a tree on a grassy hillside"
)
)
.Project(Builders<MyDocument>.Projection
.Include(d => d.Name)
.Include(d => d.Email))
.Limit(20);
var results = await cursor.ToListAsync();
var firstDocument = results[0].Document;
Remarks
This cursor is returned by FindAndRerank<TResult>(CollectionFilter<T>, CollectionFindAndRerankOptions<T>) and provides a fluent API for applying settings such as filtering, sorting, limiting, including projecting rows into a different result type. It supports both synchronous and asynchronous iteration patterns.
Methods
Clone()
Creates a new cursor instance with the same configuration.
public override CollectionFindAndRerankCursor<T, TResult> Clone()
Returns
- CollectionFindAndRerankCursor<T, TResult>
A new cursor instance.
CloneWith(Filter<T>, BaseFindAndRerankOptions<T, CollectionFindAndRerankSortBuilder<T>>)
Creates a new cursor instance with updated filter and options.
protected override CollectionFindAndRerankCursor<T, TResult> CloneWith(Filter<T> filter, BaseFindAndRerankOptions<T, CollectionFindAndRerankSortBuilder<T>> options)
Parameters
filterFilter<T>The filter to apply.
optionsBaseFindAndRerankOptions<T, CollectionFindAndRerankSortBuilder<T>>The find options to use.
Returns
- CollectionFindAndRerankCursor<T, TResult>
A new cursor instance.