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
TThe type representing the record or row being queried.
TResultThe type to deserialize the results to (e.g., when using projections).
TSortThe type of sort builder to use (such as CollectionFindAndRerankSortBuilder<T>).
TCursorThe concrete cursor type for fluent method chaining.
- Inheritance
-
AbstractCursor<TResult>PaginatedCursor<T, TResult, BaseFindAndRerankOptions<T, TSort>, TCursor>FindAndRerankCursor<T, TResult, TSort, TCursor>
- Implements
-
IEnumerable<TResult>IAsyncEnumerable<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
hybridLimitsintThe 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
vectorLimitintThe maximum count of returned documents for the vector sub-search.
lexicalLimitintThe 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
includeboolWhether 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
rerankOnstringThe 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
expressionExpression<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
rerankQuerystringThe 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
sortTSortThe 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);