This article covers a Bloomreach Experience Manager version 13. There's an updated version available that covers our most recent release.

Sorting search results in a query can only be done on direct properties of documents

You typically order your query results in a specific way:

final HstQuery hstQuery = HstQueryBuilder.create(scope)
            // order by property "myproject:date", descending
            // and if the dates are the same, order by property "myproject:title", ascending

As seen above, you can sort on properties like mynamespace:date and mynamespace:title. These properties must be stored directly on the node representing a single query result. You cannot sort on properties in descendant JCR nodes (representing f.e. compound document fields). So if you have a compound type field in a document stored in child node mynamespace:address, and that node has a property mynamespace:street, then it is not possible to sort the search results on this property.

Sorting can only be done on properties directly stored on the HippoDocument.

The reason for this limitation is twofold:

  1. If your query result node has child nodes with the same name (same name siblings), then it is unclear which child node to use for the sorting. For example, if your document has two addresses, and you want to sort them by street name, which address should be used?

  2. It cannot perform, as it cannot be indexed properly: Think about sorting on a property of a descendant node 5 levels deeper. This cannot be indexed, and therefore cannot be searched efficiently.

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?