Monday, April 17, 2017

Coveo Sorting Part 1 - On the Rendering

Coveo provides lot of tools and places where you could provide a sort mechanism.  First things first, sort is the most important piece that goes with listing.  If the listing of search results that you are showing to end user are not sorted per either business drive or more power to user where the user could actually select how he/she wants to sort their results is the key for the user to be able to find what they are looking for. 

Steps to get sorting working 

  1. Firstly define which field either sitecore or computed field you are going to use as a sort field.
  2. Note that OOTB, not all fields are sortable and you will need to configure and ensure that the field you are going to base the sort on is Coveo sortable.  For example - string fields are not inherently sortable while number fields are. 
  3. If the field you decided as sort field is not inherently sortable, configure it per directions listed here by Coveo documentation and rebuild your indexes.
    https://developers.coveo.com/display/public/SitecoreV4/Making+a+Sitecore+Field+Sortable
  4. After this step, always do a sanity check on admin tool that this field has a checkbox for sortable. 

Now that you have basic configuration ready, the next step is fairly simple.  Go to presentation on the template which has your coveo rendering on which you would like to apply sort.  Pull open the properties of Coveo rendering and you will see a Default Sort order section like below.  Input three parameters it looks for - 

  • Default Sort Type - Field | Date | Relevancy - I found Field and Date to be extremely useful 
  • Default Sort Direction - Ascending | Descending 
  • Default Sort Field - You have a pick list provided by Coveo which is a searchbox where you can type and find the sortable field you are looking for.  We are using December 2016 version of Coveo which has an active bug, so, we had to use GUID as a workaround instead of using field picker.   See an example on the screenshot below 

After you pick everything coveo is expecting, give it a spin -  Go to the page where this rendering exists and check what is happening on the query request.  You should see the below two populate with the field you picked and direction you mentioned on default sort order.  If you do not see this then the sort would not be working and you will have to debug further.  Couple times, it is due to presentation being overridden, so try resetting it before you panic. 😱




Now, all this works beautifully if you have just the basic Coveo custom rendering on your page.  Now, how will you make sort work with tabs, how about facet ordering.  What happens when you have both going.  How about if you need to apply sort ordering on a custom or computed field.  I will post details about these scenarios soon.  More to come later....Sorting O what fun. 😆

Happy Sitecoring and have fun every one.  Between, on a side note, last month I presented at LASUG about Coveo, if you wanna to check it out here is the link to youtube video.  Post your comments.





No comments :

Post a Comment