Search text for whole word matches
I recently received a request from a user to looking to be able to search for
terms whilst not returning partial matches. For instance, given I am searching
for the word
"tension", I would not expect
"extension" to be returned
In version 1.6 it is now possible to restrict your search to only return records where whole words are matched.
var result = data.Search(x => Name) .Matching(SearchType.WholeWords) .Containing("tension");
We can also mix the search types. The following example matches
against whole words only but then reverts a search for
"search" to match
against any occurrence,
var result = data.Search(x => Name) .Matching(SearchType.WholeWords) .Containing("tension"); .Matching(SearchType.AnyOccurrence) .Containing("search");
The above code will return
"tension research" but would not return
This feature is also available to
Thanks to Rob for getting in touch via a previous post.
This feature has come about purely because he got in touch.
PM> Install-Package NinjaNye.SearchExtensions