Skip to content

Commit

Permalink
Improve game search ranking (#1756)
Browse files Browse the repository at this point in the history
* improve game search ranking

* add slash replacements so that postgres properly splits the terms for the search
  • Loading branch information
Masterjun3 authored Feb 1, 2024
1 parent a156c48 commit a6b3c4a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions TASVideos/Pages/Search/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ public async Task<IActionResult> OnGet()
.ToListAsync();

GameResults = await _db.Games
.Where(g => EF.Functions.ToTsVector("simple", g.DisplayName + " || " + g.Aliases + " || " + g.Abbreviation).Matches(EF.Functions.WebSearchToTsQuery("simple", SearchTerms)))
.OrderByDescending(g => EF.Functions.ToTsVector("simple", g.DisplayName + " || " + g.Aliases + " || " + g.Abbreviation).RankCoverDensity(EF.Functions.WebSearchToTsQuery("simple", SearchTerms), NpgsqlTsRankingNormalization.DivideByLength))
.Where(g => EF.Functions.ToTsVector("simple", g.DisplayName.Replace("/", " ") + " || " + g.Aliases + " || " + g.Abbreviation).Matches(EF.Functions.WebSearchToTsQuery("simple", SearchTerms)))
.OrderByDescending(g => EF.Functions.ToTsVector("simple", g.DisplayName.Replace("/", " ")).ToStripped().Rank(EF.Functions.WebSearchToTsQuery("simple", SearchTerms), NpgsqlTsRankingNormalization.DivideByLength))
.ThenBy(g => g.DisplayName.Length)
.ThenBy(g => g.DisplayName)
.Skip(skip)
.Take(PageSize + 1)
Expand Down

0 comments on commit a6b3c4a

Please sign in to comment.