

If you returned a result, then your index/code is setup correctly and you can test excluding specific content.
#Remove smart search code
If you cannot return a result, please check your search index settings and re-verify the code in your new class is correct. Once this index has been rebuilt, search for SomeTestText in your search web part to ensure a result has been returned and the search index is working correctly. Add a new Smart search dialog with results web part to your Home page and assign the DoNotSearchExample index to this search web part.Īdd a new Editable text web part to your Home page and add SomeTestText to the content section.Īfter saving this page, go to Site Manager -> Administration -> Smart search -> edit the DoNotSearchExample index -> General, and rebuild the index.

You have created the search index, and created a new class containing the example code, so let’s perform a test. Result = Regex.Replace(result, "\\s+", " ", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Compiled) Result = Regex.Replace(result, "]*>", " ") Result = Regex.Replace(result, "", " ", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Compiled) Result = originalHtml.Remove(startIndex, endIndex - startIndex)

Var endIndex = originalHtml.IndexOf("", startIndex) + "".Length Var startIndex = originalHtml.IndexOf("") define div tag to exclude from search results Static string SearchHelper_OnHtmlToPlainText(string plainText, string originalHtml) SearchHelper.OnHtmlToPlainText += new SearchHelper.HtmlToPlainTextHandler(SearchHelper_OnHtmlToPlainText) Assigns a handler for the OnHtmlToPlainText event / Called automatically when the application starts. Private class DocumentCrawlerContentLoaderAttribute : CMSLoaderAttribute / Attribute class for assigning event handlers. You can create a new class in your App_Code folder and add this code: The example code below won’t index any content contained within the do-not-search div tag. Please remember to assign this index to your current site (Sites tab), and add your Culture to the index (Cultures tab). Go to Site Manager -> Administration -> Smart search -> New index, create a new index called DoNotSearchExample which uses a Document crawler Index type, and only searches the Home page as shown below. The following example search index is setup as a Document crawler Index type, and is set to only search the Home page for simplicity.
#Remove smart search how to
This article describes how to exclude certain elements from a given page within the Smart Search index.įor Kentico 8 API and customization please see the Defining page indexes documentation.
