MODiX icon indicating copy to clipboard operation
MODiX copied to clipboard

Improve user searching

Open spixy opened this issue 5 years ago • 4 comments

Improve searching in mod.gg/userlookup.

  1. allow searching for users with just 1 or 2 letter usernames?

image

  1. fix searching result not including user who surely exists

image

spixy avatar Feb 01 '20 02:02 spixy

  1. That's probably a good idea, but we should make sure this isn't gonna put too much load on the DB or anything, trying to query that large of a resultset.

  2. The issue here is that the list is limited to only the first 10 matches. There's definitely a match for "ther#6028", it's just sorted farther down, so you don't see it. And the only way you could further qualify the search would be by adding a "#", which the search algorithm doesn't support. For this, we should A) add support for discriminator searching, whether by specifying it via "#", or with a separate search box, and B) probably have the results sorted by match rank, which is something the database should support natively as part of its text search API. Dunno if this would be directly supported in EF.

JakenVeina avatar Feb 01 '20 21:02 JakenVeina

B) probably have the results sorted by match rank, which is something the database should support natively as part of its text search API. Dunno if this would be directly supported in EF.

A rudimentary solution would be to check both the equivalent of Contains() and StartsWith() in the query, and sort by StartsWith first. Shouldn't be too much more expensive but could be difficult to express in EF.

jmazouri avatar Feb 02 '20 16:02 jmazouri

.Where(...)
.Select(user => new
{
    StartsWith = user.Username.StartsWith(query),
    Model = ModixUser.FromIGuildUser(user)
})
.OrderByDescending(x => x.StartsWith)
.Take(10)
.Select(x => x.Model);

should be enough (and its compilable by EF)

spixy avatar Feb 04 '20 20:02 spixy

Addendum...

.OrderByDescending(x => x.StartsWith)
.ThenBy(x => x.Model.Username)

JakenVeina avatar Feb 06 '20 23:02 JakenVeina

As part of a new effort to refocus on priorities, I will close this. If you feel this is imperative to the bot, a new issue can be opened to supersede this.

patrickklaeren avatar Mar 26 '24 14:03 patrickklaeren