Typo-tolerant Search in Kentico 12 MVC

Yowaraj Chhetri asked on November 6, 2019 23:56

Hi, Is it possible to configure Typo-tolerant smart Search in Kentico 12 MVC. For portal engine there is a support for this in the webpart, but I am not sure about MVC as there is no mention of this feature in the documentation.

Can anyone suggest me how can we achieve this.

Thanks in advance

Correct Answer

Peter Mogilnitski answered on November 7, 2019 01:00

It should work for both MVC or portal, doesn't matter.
The search API are the same. Under the hood it is the Lucene fuzzy search anyway.

You have to experiment for example:

// Gets the search index
SearchIndexInfo index = SearchIndexInfoProvider.GetSearchIndexInfo("NewIndex");

if (index != null)
{
    // Prepares the search parameters
    SearchParameters parameters = new SearchParameters()
    {
        SearchFor = "home~",
        ...
    };

    // Performs the search and saves the results into a DataSet
    System.Data.DataSet results = SearchHelper.Search(parameters);

    if (parameters.NumberOfResults > 0)
    {
        // The search found at least one matching result, and you can handle the results

    }
} 

you can use SearchSyntaxHelper.TransformToFuzzySearch to prepare your search query, but it is the Lucene syntax anyway.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Yowaraj Chhetri answered on November 7, 2019 04:30

Thank you, after enabling the fuzzysearch to true while preparing the searchcondition it all worked well.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.