EF Core npgsql order by Rank on full text search

EF Core npgsql order by Rank on full text search

正在尝试计算排名搜索顺序的 EF Core / npgsql 组合...

var models = await _dbContext.ThreadDocuments
    .Where(td => td.SearchVector.Matches(filters.SearchTerm))
    .OrderByDescending(td => td.SearchVector.Rank(new NpgsqlTsQuery(filters.SearchTerm)))
    .Select(td => td.Document)
    .Take(100)
    .ToListAsync();

NpgsqlTsQuery 是抽象的,子 类 不适合。

我找不到示例,Rank 的文档也很稀疏

https://www.npgsql.org/efcore/mapping/full-text-search.html?tabs=pg12%2Cv5

如何用 npgsql 构建 TsQuery(这么棒的端口)

.OrderByDescending(td => td.SearchVector.Rank(EF.Functions.ToTsQuery(filters.SearchTerm)))