Try our conversational search powered by Generative AI!

Episerver find - how to do fuzzy search



I am trying to implement fuzzy search using episerver find.

I have a page that contains the word "Salmon". If i type the word "Salmin" or "Salmo" i get 0 results. If i type the word "Salmon" i get 10 results which is correct.

But i wonder why i do not get any results if i spell lets say just one character wrong.

Below you can see how i query using episerver find and none of the result sets contains any hits when searching for "Salmin":

                var currentSubsite = _contentLoader.Get(new ContentReference(id));
                var unifiedSearch = SearchClient.Instance.UnifiedSearchFor(term).Filter(x =>
                    !x.MatchTypeHierarchy(typeof (PageData)) | ((PageData) x).Ancestors().Match(currentSubsite.ContentLink.ID.ToString()));

                result = unifiedSearch.GetResult(); // Filter(x => x.SearchText.Fuzzy(term)) - MoreLike(term)

                var unifiedSearchMoreLike = SearchClient.Instance.UnifiedSearchFor(term).MoreLike(term);
                var moreLikeResult = unifiedSearchMoreLike.MoreLike(term).GetResult();

                var unifiedSearchFuzzy = SearchClient.Instance.UnifiedSearchFor(term).Filter(x => x.SearchText.Fuzzy(term));
                var fuzzyResult = unifiedSearchFuzzy.GetResult();

                var forResult = SearchClient.Instance.Search().For(term).GetContentResult();

                var unifiedSearchApplyBestBets = SearchClient.Instance.UnifiedSearchFor(term).ApplyBestBets(3);
                var applyBestBetsResult = unifiedSearchApplyBestBets.GetResult();

And some Fuzzy extensions:

    public static class FilterExtensions
        public static DelegateFilterBuilder Fuzzy(this string value, string almost)
            return new DelegateFilterBuilder(field => new QueryFilter(new FuzzyQuery(field, almost)));

        public static DelegateFilterBuilder Fuzzy(this string value, string almost, double minSimilarity)
            return new DelegateFilterBuilder(field => new QueryFilter(new FuzzyQuery(field, almost) { MinSimilarity = minSimilarity }));

In Episerver find I have seen terms like "ApplyBestBets", "MoreLike", "For" and there is also a "FuzzyQuery". To honest i am a bit confused on what extactly implements fuzzy search. I must be missing something here. Does anyone know what i might do wrong? How to add fuzzy search

Dec 05, 2016 12:47

If you return spelling suggestions, do you get salmon there?

Dec 19, 2016 0:06

Thanks for replying.

How do i return spelling suggestions?

I actually managed to get it working using this filter i implemented:

public static ITypeSearch<T> FuzzyFilter<T>(
              this ITypeSearch<T> search,
              Expression<Func<T, string>> fieldSelector,
              string almost,
              double? minSimilarity = null,
              double? boost = null)
            var fieldName = search.Client.Conventions

            var wildcardQuery = new FuzzyQuery(fieldName, almost.ToLowerInvariant())
                MinSimilarity = minSimilarity,
                Boost = boost

            //Add it to the search request body
            return new Search<T, WildcardQuery>(search, context =>
                if (context.RequestBody.Query != null)
                    var boolQuery = new BoolQuery();
                    boolQuery.MinimumNumberShouldMatch = 1;
                    context.RequestBody.Query = boolQuery;
                    context.RequestBody.Query = wildcardQuery;
Dec 21, 2016 14:43

Hi Jeppe,

What version of Find/CMS are you using? I had found that same extension for Wildcard search and it was working awesome. At some point after upgrading to latest version of Find, it stopped working. It just returned everything regardless of the query. I am not sure what caused it to stop working. It could have been totally unrelated to the FInd upgrade. I am curious as to what version you are on, as I may be able to rule out the upgrade as the cause of my issue.



Dec 21, 2016 18:38

Hi John,

Sounds very strange.

My versions are:

  • Episerver Find -
  • Episerver CMS - 9.12.2

Best regards,


Dec 22, 2016 8:04
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.