Configure Sorting and Limiting of Result Sets

Introduction

Goal

Configure sorting and limiting of result sets in a faceted tree.

Background

In a faceted tree, documents in a result set are by default sorted by their score. It is possible to configure a different sorting and sorting order, as well limit the number results.

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

Example

Sort the Documents in the Result Set

By default, results are ordered by score, with the best score first.

To sort by one or more document properties, use the multi-valued String property hippofacnav:sortby:

/content/documents/myproject:
  /faceted-news:
    jcr:primaryType: hippofacnav:facetnavigation
    hippo:docbase: d2b1775c-fb97-4080-bd66-ede4ac874b5a
    hippofacnav:facets: [ myproject:author, myproject:source ]
    hippofacnav:facetnodenames: [ Author, Source]
    hippofacnav:sortby: [ myproject:date, myproject:title]

The default sort order is ascending. To specify the sort order for each sortby property, use the multi-valued String property hippofacnav:sortorder:

    hippofacnav:sortorder: [ descending, ascending ]

The number of values and the order of the values of hippofacnav:sortorder must match those of hippofacnav:sortby.

Optionally, specify a sort function for each sortby property to sort either case-insensitive (sort function lower-case) or ignoring diacritics (sort function normalize) using the multi-valued String property hippofacnav:sortfunction:

    hippofacnav:sortfunction: [ lower-case, normalize ]

The number of values and the order of the values of hippofacnav:sortfunction must match those of hippofacnav:sortby.

When hippofacnav:sortfunction is present, a sort function must be specified for each sortby property. It is not possible to specify an empty string to indicate default (case-sensitive) sorting. HSTTWO-3967 aims to make this possible.

Limit the Number of Documents in the Result Set

To limit the number of results in any result set in the faceted tree, add the optional Long property hippofacnav:limit. This is recommended for performance and memory reasons, as the result set can easily contain tens/hundreds of thousands of results. You most likely will only need no more then X of them. Set this as limit. Not doing so can lead to unnecessary high memory and CPU loads.

/content/documents/myproject:
  /faceted-news:
    jcr:primaryType: hippofacnav:facetnavigation
    hippo:docbase: d2b1775c-fb97-4080-bd66-ede4ac874b5a
    hippofacnav:facets: [ myproject:author, myproject:source]
    hippofacnav:facetnodenames: [ Author, Source ]
    hippofacnav:limit = 100

 

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?