Configure Sorting and Limiting of Facet Values - BloomReach Experience - Open Source CMS

This article covers a Hippo CMS version 11. There's an updated version available that covers our most recent release.

01-06-2017

Configure Sorting and Limiting of Facet Values

Introduction

Goal

Configure sorting and limiting of facet values in a faceted tree.

Background

In a faceted tree, facet values are by default sorted by their result counts. It is possible to configure a different sorting and sorting order, as well limit the number of facet values.

Example use cases are a date facet with resolution "year" sorted descending on facet value (year), and a tag cloud showing the 10 most used tags.

This page is about sorting and limited facet values. To sort and limit the result sets in a faceted tree, see Configure Sorting and Limiting of Result Sets.

Configuration

Facet value ordering and limit are configured per facet in the hippofacnav:facetnodenames property of a faceted tree configuration. The following configuration parameters are available:

  • sortby (type: String) with possible values:
    • count (sorting on count, descending is the default, except for ranges)
    • facetvalue
    • config (in case of configured ranges: the default order for config is ascending, which is the order how it is configured)
  • sortorder (type: String, options: descending/ascending)
  • limit: (type: int) the number of unique facetvalues shown (useful for tag cloud's and performance when thousands of unique facets are present)

Ordering on facetvalue works for Long, Double, Date, and String values. A runtime logical check is performed to determine whether we are dealing with numerical values or Strings.

Examples

Sort by Facet Value

Suppose you have product documents with a String property myhippoproject:brand. and you want to sort the brands by name. This can be configured as follows:

/content/documents/myhippoproject
  + faceted-products [hippofacnav:facetnavigation]
    - hippo:docbase = d2b1775c-fb97-4080-bd66-ede4ac874b5a
    - hippofacnav:facets = 
      - myhippoproject:brand
    - hippofacnav:facetnodenames = 
      - Brand${sortby:'facetvalue', sortorder:'ascending'}

Limit the Number of Facet Values

Suppose you have thousands of brands and only want to show the top 25 brands. You can achieve this by configuring a limit as well:

/content/documents/myhippoproject
  + faceted-products [hippofacnav:facetnavigation]
    - hippo:docbase = d2b1775c-fb97-4080-bd66-ede4ac874b5a
    - hippofacnav:facets = 
      - myhippoproject:brand
    - hippofacnav:facetnodenames = 
      - Brand${sortby:'facetvalue', sortorder:'ascending', limit:25}

Sort by Configured Ranges

Suppose you also configure a facet value ranges for myhippoproject:brand. In that case, you can order the facet values on the configured range names as follows:

/content/documents/myhippoproject
  + faceted-products [hippofacnav:facetnavigation]
    - hippo:docbase = d2b1775c-fb97-4080-bd66-ede4ac874b5a
    - hippofacnav:facets = 
      - myhippoproject:brand$[{name:'all', resolution:'string'},
                              {name:'a - f', resolution:'string', lower:'a', upper:'g'},
                              {name:'g - m', resolution:'string', lower:'g', upper:'n'},
                              {name:'n - z', resolution:'string', lower:'n', upper:'{'}]
    - hippofacnav:facetnodenames = 
      - Brand${sortby:'config', sortorder:'descending'}

 

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?