const results = await collection.findAndRerank({
category: 'books',
}, {
sort: { $hybrid: { $vectorize: 'fantasy novels', $lexical: 'dragons' } },
limit: 5,
timeout: 10000,
});
You can also use fluent builder methods on the cursor:
const cursor = collection.findAndRerank({ category: 'books' })
.sort({ $hybrid: { $vectorize: 'fantasy novels', $lexical: 'dragons' } })
.limit(5)
.includeScores(true);
const results = await cursor.toArray();
Overview
The options for a
findAndRerankcommand on a Collection.