Ranking search results in Kentico

#Kentico development #Kentico Kontent

SHARE

 
This post shows how you could override search results order.

 

Problem

Recently I received the request from the client to build search results page. This page should be a default search results, where all results are ordered by relevance, except there are items (pages), those should appear always at the top of others results, even if they match search criteria just once.

Solution

I started to look for solutions and, at the very beginning, I thought about different types of customization: custom search results web part, overriding built in search functionality, etc. But I was enough lucky to come out with really simple solution, which does not require customization (customization is evil!), and I'd like to share my approach with you.

So I decided to add Search Rank field to the page type(s), which will need to appear on the very topo in the results. I setup zero as a default value for that fields. So all pages of the type will be assigned to zero by default. If we need some particular result to appear at the top, all we need is just specifying any positive number for the fields. Also you can differentiate pages, those appear before all other assigning different Search Rank to them, e.g.: pages with Search Rank equal 1 appears before regular search results; pages with Search Rank equals 5 are more import and appears before pages with Search rank equal 1; Items with Search Rank equal 10 are the most important and appears at the very top of the search results list.

Next step we have to make is including Search Rank field into a search index. This could be done in Page Types application by editing appropriate Page Type Search fields. Just navigate SearchRank field and check Content and Searchable check boxes, save changes.

Now we need to rebuild search index(es) used by the Smart search results web part on the search results page. So open Smart Search application, navigate appropriate Search Index and click rebuild.

The step in this process is setting up correct search order for the Smart search results. It should be following:

SearchRank desc, ##SCORE##

Okay, we are done from technical stand point. The only thing we left is content editors' piece, which requires going and populating Search Rank field for needed documents.

Summary

So you can see that suggested approach is really simple, easy to implement and does not require customization, which always is a huge advantage. It allows us to combine together Kentico out of the box functionality with requirement specific one in order to meet our goal. I believe that this could be useful in many other scenarion, those are not described in this post.

If you have any question on the approach, or want to share your experience solving similar problems - just leave your comment under the post. I really appreciate any feedback.

 

Author

Check other articles

Bitsorchestra
5 5

What our clients say

Bits Orchestra team are outstanding developers​. They listen carefully to our business needs and easily turns our business objectives into a well thought out and executed development effort. Roman is very bright and definitely the most capable developer that has worked on our site. He is not only a Kentico expert but has successfully tackled other complicated development assignments demonstrating expertise in both front and backend development. Roman takes initiative to suggest enhancements that make site maintenance easier while improving the customer experience. The team is very responsive to our work requests and has great follow up. They have also worked very business partners and this has reflected positively on our company. Roman is a true partner for us and a tremendous asset to our organization. We will continue to work with them and would highly recommend Roman and his team for your development needs. He and his team will exceed your expectations!
 Alan Lehmann
Alan Lehmann
President at In energy sector

What our clients say

The Bits Orchestra team does excellent work. They are always available and I appreciate our frequent calls and screen-shares together. Their dedication to the projects and knowledge of Kentico is outstanding. They truly care about the quality of their work, and became a part of our team easily!
Shena Lowe
Shena Lowe
Managing Partner at Consensus Interactive

What our clients say

We hired Roman for a Kentico analysis project and have been very satisfied. He is very skilled and professional. We are looking to hire him and his team again on future projects.
Sylvain Audet
Sylvain Audet
CEO at MyDevPartner.com

What our clients say

Roman and team have taken over an existing Kentico EMS site for a large US Oil Company. So far, they have handled every single request that we have thrown at them and these were diverse, challenging, often bespoke, usually urgent and almost daily, over the last 11 months. Their work is of an extremely high quality, they are capable, quick and we have great confidence in the support that we are getting.
Jon Hollis
Jon Hollis
Head of Web Development at confidential

What our clients say

Bits Orchestra team was very helpful, they had a good understanding of the brief and deep knowledge of the system. They were always keen to provide advice and recommendations that benefit the project substantially.
Ramon Lapenta
Ramon Lapenta
Senior Front End Developer at Cyber-Duck Ltd