Brian McKeiver's Blog

Improve Your Kentico Site Search Experience in Only a Matter of Minutes - Part 3


Introduction

This is part 3 of How to Improve Your Kentico Site Search Experience in Only a Matter of Minutes. Please be sure to read part 1 and part 2 first before reading this post. The third part of this blog post series illustrates other Smart search filter options and real world examples.

 

Smart Search Filter – Product Public Status Example

In my opinion, this will be your most widely used example, and it would be the best use of the system as I see it because it is an example of a Dynamic Conditional filter. You can generate a query from whatever object in Kentico you want. However, it must be in your Smart Search index (as long as the fields of the content as marked as Searchable). For this next example I am showing how to generate a filter from the Public Status field of an e-commerce product in Kentico.

This filter below uses the radio button Filter mode to render the choice of a status, (ex. New, BestSeller) this way the visitor can only filter by one status at a time instead of multiple.

 

Kentico 8 Smart Search Filter Dynamic Public Status

 

The Query name field is set to a query that already exists in the system:


--Ex: Filtering results by a SKU Public Status to show a list of radio buttons with a label of each status name:
SELECT '+skupublicstatusid'
         ,+'(int)'+ Convert(varchar(20), PublicStatusID)
         ,PublicStatusName
FROM [dbo].COM_PublicStatus 
WHERE [PublicStatusEnabled] = 1  AND [PublicStatusSiteID] = 3
ORDER BY ##ORDERBY##

 

The Filter clause is set to Must, and the Filter is conditional bit is checked.The end result is a nice set of radio buttons that filter down the search results by a single status:


Kentico 8 Smart Search Statuses
 

 

Smart Search Filter - Controlling Results Ordering Example

This configuration of the Kentico Smart search filter allows you to change the sequence of the results instead of narrowing down the results. The key with this configuration is to un-check the Filter is conditional property. That tells the system that this filter will change the sequence of the results from either the highest matching score (relevance), by the content creation date, or by a combination of relevance and creation date.

Kentico 8 Smart Search Filter Ordering

 

The Values field is set to:

##SCORE##;;Relevance
documentcreatedwhen DESC;;Newest
SKUPrice DESC;;Price descending
SKUPrice;;Price asc

 

The Filter clause is set to Must, and the Filter is conditional bit is un-checked. As you can see in the lower part of the next screen shot the Order By filter is set to Price asc. This sorts the Bolivia coffee to the first result because it is the lowest priced coffee for sale.


Kentico 8 Smart Search Ordering Results


 

More Smart Search Filter Examples

The following configurations can be used as references to some additional filter values and queries for other types of filters in your Kentico instance. Having more examples is what actually inspired me write this blog post because I could not really find many real world examples.

 

Example 1 - Document Tags Conditional

Kentico 8 Smart Search Filter Dynamic Tags

 

The Query name field is set to a query that already exists in the system:

--Ex: Filtering results by a tagname of Fun and to show a checkbox with a label of Fun:
--  +documenttags{0};Fun;
SELECT ##TOPN## '+documenttags{0}', TagName, 'TagDisplayName'=TagName
FROM CMS_Tag
WHERE ##WHERE##
ORDER BY ##ORDERBY##

 

The Filter clause is set to Must, and the Filter is conditional bit is checked.The end result is a nice set of checkboxes for each tag in your Kentico instance, one or many tags may be checked:


Kentico 8 Smart Search Filter Dynamic Tag Results
 

 

Example 2 - Page Created When / Date Range Conditional

Kentico 8 Smart Search Filter Dynamic Created Date

 

The Values field is set to:

+_created;[{ToSearchDateTime(CurrentDateTime.AddDays(-7))#} TO ToSearchDateTime(CurrentDateTime)#}];Past week
+_created;[{ToSearchDateTime(CurrentDateTime.AddDays(-30))#} TO {ToSearchDateTime(CurrentDateTime)#}];Past month
+_created;[{ToSearchDateTime(CurrentDateTime.AddDays(-365))#} TO {ToSearchDateTime(CurrentDateTime)#}];Past year
Note on this snippet, inside of the open and close curly brackets you need to add a percent sign. See documentation.

 

The Filter clause is set to Must, and the Filter is conditional bit is un-checked. The end result is a choice of radio buttons for when the search result item was created: 



Kentico 8 Smart Search Filter Dynamic Created Date Results
 

 

Example 3 - Textbox / Keyword Conditional

Kentico 8 Smart Search Filter Text

 

The Values field is set to:

+(DocumentTags{0} OR _content{0})

 

The Filter clause is set to Must, and the Filter is conditional bit is un-checked. The end result is a texbox where users can enter a keyword to narrow down the results. Notice how the word slim is entered in the textbox and slim appears in the product summary field: 


Kentico 8 Smart Search Filter Text Results
 

 

Example 4 - SKUPrice Conditional

Kentico 8 Smart Search Filter SkuPrice

 

The Values field is set to:

+SKUPrice;[(int)0 TO (int)10]; <= $10
+SKUPrice;[(int)11 TO (int)100]; $11 - $100
+SKUPrice;[(int)101 TO (int)1000]; $101 - $1000

 

The Filter clause is set to Must, and the Filter is conditional bit is un-checked. The end result is a choice of radio buttons for when the search result item was created: 


Kentico 8 Smart Search Filter SkuPrice Results


Hopefully this group of examples shows you some of the possibilities that the Kentico Smart search engine has.
 

 

Still Room for Improvement

If you are a long time reader of my blog, you know that I am a fan of Kentico, and I speak highly of the software any time I can. But I feel it is my job to also be honest with my audience. There are two things that will not happen out of the box when it comes to using the filtering system. The first is getting the number of search results per smart search filter to show next to each single checkbox or radio button. There is just no easy way to have each individual number of items show for say the price range of $11 - $100, or the number of items for the Brewer product type. All my research points to having to create a custom solution to do this. I can also say that this is a common request that I get from my projects that I lead at BizStream. It is doable, just not that easy, and not always done with this group of web parts.

The second area for improvement in the Kentico Smart search filters that I think Kentico needs to work on is being able to make the filters themselves more dynamic based on what results are showing. Most people expect Amazon or Walmart like filtering functionality when talking about facetted search. That is they expect that if I am showing a list of products, only the Product based filters would show up on the filter bar (Status, Price, Product Type), and if I am looking at a list of articles, content based filters would show up (keyword, tags, created date). Right now there is no way for the results to dynamically adjust the filters that show up on the search results page, in fact there is not really an easy way to get the selected values of which filters are checked at runtime either, unless you drop fully into a custom web part.

Hint, hint Kentico…

 

Conclusion

Well there you have it. I hope I have inspired you to take your on-site search experience up a notch. Let me know in the blog post comments if you found this approach useful, and if you have your own awesome Smart search filter queries to share please post that in the comments as well. I’d love to know other creative ways that Kentico developers out there are using this aspect of Kentico. Thanks for reading.