Wednesday, December 7, 2016

Tip for writing multiple XRANK’s or nested XRANK’s

image

My colleague Tarjei had a requirement to list items in a particular order on a page. The items were tagged with different phases and he wanted items to be listed in this order:

  • Concept
  • Planning
  • Doing
  • Finishing
  • Realization
  • No phase

The easiest approach I have found doing these types of custom ordering is using XRANK with bulk interval boosts to ensure the order. Pick an interval which suits you. If you need multiple levels of sorting add secondary sorts with intervals less than the major range.

One level sorting:

  • Concept cb=100
  • Planning cb=90
  • Doing cb=80
  • Finishing cb=70
  • Realization cb=60
  • No phase cb=50

Two level sorting:

  • Concept cb=1000
  • Planning cb=900
  • Doing cb=800
  • Finishing cb=700
  • Realization cb=600
  • No phase cb=500
  • Word cb=50
  • Excel cb=40
  • PDF cb=30

Once you have the logic in place you need to write a nested XRANK statement. This often gets confusing with getting parenthesis correct. A Pro tip is to use Freshness Boost Generator in the SharePoint Search Query Tool as a starting point, and then replace your matching and boost expressions as needed. Say you need 6 sorting intervals. Set the constant and max boost values to 0, and add 6 day intervals as seen in the image below. Copy the resulting expression and change the write>{} parts and XRANK(cb=) parts as needed – with all parenthesis intact at the right places.

image