Table of Contents

Class FindAndRerankCursor<T, TResult, TSort, TCursor>

Namespace
DataStax.AstraDB.DataApi.Core.Enumeration
Assembly
DataStax.AstraDB.DataApi.dll

A fluent API cursor for running a find-and-rerank query and enumerating records or rows with filtering, sorting, and projection capabilities.

This cursor extends PaginatedCursor<T, TResult, TOptions, TCursor> to provide query-specific operations like sorting or setting rerank details.

It supports both synchronous and asynchronous iteration patterns.

Use the fluent methods to refine your query, then iterate using foreach, LINQ, or manual cursor navigation.

public abstract class FindAndRerankCursor<T, TResult, TSort, TCursor> : PaginatedCursor<T, TResult, BaseFindAndRerankOptions<T, TSort>, TCursor>, IDisposable, IEnumerable<TResult>, IEnumerable, IAsyncEnumerable<TResult> where T : class where TResult : class where TSort : FindAndRerankSortBuilder<T> where TCursor : FindAndRerankCursor<T, TResult, TSort, TCursor>

Type Parameters

T

The type representing the record or row being queried.

TResult

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

TSort

The type of sort builder to use (such as CollectionFindAndRerankSortBuilder<T>).

TCursor

The concrete cursor type for fluent method chaining.

Inheritance
PaginatedCursor<T, TResult, BaseFindAndRerankOptions<T, TSort>, TCursor>
FindAndRerankCursor<T, TResult, TSort, TCursor>
Implements
IEnumerable<TResult>
Derived
Inherited Members

Methods

HybridLimits(int)

Specifies a maximum number of documents to fetch for both the vector and the lexical sub-searches.

public TCursor HybridLimits(int hybridLimits)

Parameters

hybridLimits int

The maximum count of returned documents per each sub-search contributing to the rerank step.

Returns

TCursor

A new cursor instance with the updated setting.

Examples

var cursor = collection.FindAndRerank().HybridLimits(12);

HybridLimits(int, int)

Specifies a maximum number of documents to fetch for both the vector and the lexical sub-searches.

public TCursor HybridLimits(int vectorLimit, int lexicalLimit)

Parameters

vectorLimit int

The maximum count of returned documents for the vector sub-search.

lexicalLimit int

The maximum count of returned documents for the lexical sub-search.

Returns

TCursor

A new cursor instance with the updated setting.

Examples

var cursor = collection.FindAndRerank().HybridLimits(vectorLimit: 25, lexicalLimit: 15);

IncludeScores(bool)

Specifies whether to return the scores with the results.

public TCursor IncludeScores(bool include = true)

Parameters

include bool

Whether to include the scores. Defaults to true.

Returns

TCursor

A new cursor instance with the updated setting.

Examples

TODO example

Remarks

TODO a note on the Scores being always there, just populated/empty depending on this setting.

RerankOn(string)

Specifies the field to rerank documents against.

public TCursor RerankOn(string rerankOn)

Parameters

rerankOn string

The name of the field to use for reranking.

Returns

TCursor

A new cursor instance with the updated setting.

Examples

var cursor = collection.FindAndRerank().RerankOn("title");

Remarks

We recommend using the strongly-typed version RerankOn<TField>(Expression<Func<T, TField>>).

RerankOn<TField>(Expression<Func<T, TField>>)

Specifies the field to rerank documents against.

public TCursor RerankOn<TField>(Expression<Func<T, TField>> expression)

Parameters

expression Expression<Func<T, TField>>

The expression to use to get the field name.

Returns

TCursor

A new cursor instance with the updated setting.

Type Parameters

TField

Examples

var cursor = collection.FindAndRerank().RerankOn(d => d.Title);

RerankQuery(string)

Specifies the query string to rerank against in the reranking step.

public TCursor RerankQuery(string rerankQuery)

Parameters

rerankQuery string

The query string to use for reranking.

Returns

TCursor

A new cursor instance with the updated setting.

Examples

var cursor = collection.FindAndRerank().RerankQuery("a tree on a grassy hillside");

Sort(TSort)

Specifies a sort to apply to the query.

public TCursor Sort(TSort sort)

Parameters

sort TSort

The sort to apply.

Returns

TCursor

A new cursor instance with the updated sort.

Examples

var sort = Builders<MyRecord>.CollectionFindAndRerankSort.Hybrid(d => d.Description);
var cursor = collection.FindAndRerank().Sort(sort);