Table of Contents

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

T

The type of the rows in the table.

TResult

The type to deserialize the results to (e.g., when using projections).

Inheritance
CollectionFindAndRerankCursor<T, TResult>
Implements
IEnumerable<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

filter Filter<T>

The filter to apply.

options BaseFindAndRerankOptions<T, CollectionFindAndRerankSortBuilder<T>>

The find options to use.

Returns

CollectionFindAndRerankCursor<T, TResult>

A new cursor instance.