You can use the ToRanked() method on both IQueryable and IEnumerable collections to perform a search that returns not just the matched items, but also a hit count for each item. This is useful for ordering results by relevance.
When using ToRanked(), the result is wrapped in an IRanked<T> object. The ToRanked() method uses the search terms provided in methods like Containing() and the selected properties to calculate these hit counts.
Note: The fluent ToRanked() method is the replacement for the now-deprecated RankedSearch method.
// Example: Retrieve top 10 most relevant users based on name matches
var result = context.Users.Search(x => x.FirstName, x => x.LastName, x => x.MiddleName)
.Containing("John")
.ToRanked()
.OrderByDescending(r => r.Hits)
.Take(10);