#How to fuzzy search through IQueryable.

1 messages · Page 1 of 1 (latest)

narrow tulip
#

i brought this up the other day in chat but im still trying to figure this out, so im goign to just make a full post now

#
private static IQueryable<Leaderboard> FilterBySearch(this IQueryable<Leaderboard> sequence, string? search)
{
    if (search == null)
    {
        return sequence;
    }

    string lowSearch = search.ToLower();

    return sequence.Where(leaderboard => leaderboard.Song.Id == lowSearch
                                      || leaderboard.Song.Hash == lowSearch
                                      || leaderboard.Song.Author.Contains(lowSearch)
                                      || leaderboard.Song.Mapper.Contains(lowSearch)
                                      || leaderboard.Song.Name.Contains(lowSearch));
}``` tl;dr replacing contains with a fuzzy search
olive vine
#

In case you have not solved this, Instead of contains you can use a Regex, for example if your search keyword is dog you can make a /d|o|g/g regex which will match any word that has any of the letters of the word dog ( d,o,g ) or make a regex that the word must contain all letters of the search, thats an easy way to make a faux fuzzy search

narrow tulip
#

regex only works on inputs that are constant

olive vine
#

no it does not

#

you can generate a new regex with dynamic input

narrow tulip
#

i thought i close this th

olive vine
#

?

#

whatever dude

#

im trying to help you, just say you dont want help

narrow tulip
#

i dont want your help, not personal

#

just the way im going about this changed