asp.net-coreentity-framework-coresimilarityjaro-winkler

EF Core with Jaro-Winkler similarity distance algorithm


I want to search for strings in my db with some similarity distance algorithm like Jaro-Winkler. However EF Core cannot translate such expressions. So you cannot use an expression like below:

query.Where(x => JaroWinkler.Similarity(x.Title, someText) > 0.5);

My question is how can I implement this with EF Core? Is there any way to do this?


Solution

  • Implement algorithm in your db vendor SQL dialect and register it https://learn.microsoft.com/en-us/ef/core/querying/user-defined-function-mapping

    Some db vendors have some comparisons algos or extensions for full-text search (i.e. MS Sql DIFFERENCE or FREETEXT)

    Or use in memory processing.