Smart Search Frequently Asked Questions

   —   

In this article I would like to focus on Smart search. I will cover some of the most common requirements of our clients. 

For each scenario, I will provide a question which describes the issue or requirement and the answer with the solution.

Question 1:

I am using the subset analyzer and I have a product with the name “2RE-FD-LED-1”. When I search for 2RE, it is displayed in the search results, but when I search for 2RE-FD there is no match.

Answer 1:

The subset analyser is splitting words at non-letter characters. You can modify word selection by placing custom regex in the CMSSubsetAnalyzerWordRegex web.config key. READ MORE

Question 2:

I want newest pages to be displayed higher in the search results.

Answer 2:

Boost the newest Lucene documents. Use the Search condition property of Smart Search Results web part to add an additional query text:

 _created:[2015 TO 2016]^5 _created:[2014 TO 2015]^4 _created:[2012 TO 2013]^3.

Macros can be used to generate condition as well.

Question 3:

Why is a page with the same name as the searched text displayed lower than a page with a different name?

Answer 3:

By default search is done against the _content field. It is probable that the other page contains the given keyword more times in it’s content than the page with the keyword in it’s name.

If you want the page name to have a higher impact on the score, you need to boost the name field.

  1. Set the DocumentName field as searchable.
  2. Add the following search condition to Smart Search Result web part:

DocumentName:({% QueryString.searchtext %})^[boost value]

Alternatively you can extend search results web part to modify user input to generate something like this:

+(documentname:(<user input>)^[boost value] _content:(<user input>))

Question 4:

Changes are not propagated to the index.

Answer 4:

  1. Check the queue in Smart Search application -> Tasks section. Is it halted? If yes, you should delete all the records in CMS_SearchTask database table. It is safe to truncate the table directly in SQL Server Management Studio.
  2. If not, is the task created?
    • Not created – operation is not covered to create a search task.
    • Created – task processor might not be set to run immediately. Check “CMSProcessSearchTasksByScheduler” key iny our web.config, to see if the key is set to true. READ MORE

Question 5:

Crawler index is not returning expected results.

Answer 5:

Open index in Luke (https://code.google.com/archive/p/luke/downloads). Check whether _content field is empty.

  1. Empty – Crawler requests ends with NOT OK status.
    1. Check whether the default site domain is accessible from the PC where the app is running. If not, change the crawler's domain.
    2. Using Windows Authentication? Make sure that you deny the public user for the live site (configured in web.config). Otherwise the supplied credentials won’t be used.
    3. You can run Wireshark and monitor traffic to discover the fate of the request.
  2. Not empty – Is there a redirect to a page with different content?
    1. For instance, all requests are redirected to the login page.    

Question 6:

I want to exclude part of the html from the crawler.

Answer 6:

Use the handler SearchCrawler.OnHtmlToPlainText. For more information you can read the following article http://devnet.kentico.com/articles/exclude-certain-elements-from-smart-search-index

Question 7:

I want to display the number of results next to each option in a faceted search filter.

Answer 7:

It is not possible with Lucene unless potential the number of results is very small. SQL search is recommended for this scenario.

The Lucene approach is to get all results without any limitations or paging, then filter them into categories in memory. Beware of the max results limit, it can be found in web.config key CMSSearchMaxResultsNumber.

Question 8:

I want to add a field to the smart search index.

Answer 8:

You can use the AddGeneralField method. The code could look like this:

public override void Init() { // Assigns a handler to the GetContent event for pages DocumentEvents.GetContent.Execute += OnGetProductPageContent; } private void OnGetProductPageContent(object sender, DocumentSearchEventArgs e) { // Gets an object representing the page that is being indexed TreeNode indexedPage = e.Node; e.SearchDocument.AddGeneralField("testField", "testValue", true, true); }

That is all from me, I hope this article will save you time when dealing with Smart Search.  

Share this article on   LinkedIn