A collection of extension methods to IQueryable and IEnumerable that enable easy and performance Soundex searches
$ dotnet add package NinjaNye.SearchExtensions.SoundexNinjaNye.SearchExtensions.Soundex supports converting and searching for words that sound like a given word.
SearchExtensions.Soundex is a library of IQueryable and IEnumerable extension methods to perform 'sound like' searches. More information on these packages and it's use can be found by, visiting my blog.
Soundex searchesReturning records that 'sound like' "test" using the Soundex algorythm:
Search where a single property sounds like a single search term
var result = data.SoundexOf(x => x.Property1).Matching("test")
Search where a any of multiple properties sounds like a single search term
var result = data.SoundexOf(x => x.Property1, x => x.PropertyTwo)
.Matching("test")
Search where a single property sounds like any one of multiple search terms
var result = data.SoundexOf(x => x.Property1).Matching("test", "another")
Search where a any of multiple properties sounds like any of multiple search terms
var result = data.SoundexOf(x => x.Property1, x => x.PropertyTwo)
.Matching("test", "another")
ReverseSoundex searchesAll the above soundex examples can be performed using the Reverse Soundex algorithm.
Simply substitute in the ReverseSoundexOf() method. For example:
Search where a single property sounds like a single search term
var result = data.ReverseSoundexOf(x => x.Property1).Matching("test")
Search where a any of multiple properties sounds like a single search term
var result = data.ReverseSoundexOf(x => x.Property1, x => x.PropertyTwo)
.Matching("test")
The above
SoundexOfandReverseSoundexOfmethods can also be applied toIQueryabledata. ForIQueryablewe reduce the amount of records returned from the data source as much as possible but be aware that the soundex searching is performed on the in memory collection.
For more information about the Soundex search functionality, soundex search performance, and how it has been integrated with IQueryable, please visit http://jnye.co/posts/tagged/soundex