Apply Runtime Filters to a Faceted Tree

Introduction

Goal

Apply runtime filters to a faceted tree.

Background

When configuring filters in a faceted tree, those filters are applied any time the faceted tree is navigated. The filters can't be changed on-the-fly.

A more flexible approach is provided by runtime filters. Runtime filters can be applied on-the-fly by inserting them into the faceted tree's JCR path.

This page explains runtime filters at repository level.

Faceted Navigation Combined with Free Text Search and HST Queries covers the implementation in the delivery tier.

Usage

A runtime filter is expressed as a Lucene query or as an XPath constraint between square and curly brackets and added to the JCR path of the faceted tree:

/content/documents/myproject/faceted-news[{expression}]/

In a local development environment, the easiest way to try out a runtime filter is by using the Repository Servlet:

http://localhost:8080/cms/repository/content/documents/myproject/faceted-news[{expression}]/

Examples

Free Text Query

Only include documents which contain the word 'hippo':

/content/documents/myproject/faceted-news[{'hippo'}]/

Only include documents from 2017 which contain the word 'hippo':

/content/documents/myproject/faceted-news[{'hippo'}]/Year/2017

Only include documents from 2017 which contain the word 'hippo' AND 'gogreen':

/content/documents/myproject/faceted-news[{'hippo gogreen'}]/Year/2017

XPath Queries

Only include documents from 2017 which contain the word 'hippo' AND 'gogreen' (equivalent to the previous example):

/content/document/myproject/faceted-news[{xpath(//*[jcr:contains(.,'hippo')])}]/Year/2017

Only include documents from 2017 of which the myproject:location property has the value 'Mountain View':

/content/document/myproject/faceted-news[{xpath(//*[myproject:location='Mountain View'])}]/Year/2017

Only include documents which contain the word 'hippo' and boost (i.e. rank higher) results which also have a myproject:title property containig the word 'hippo':

/content/document/myproject/faceted-news[{xpath(//*[jcr:contains(.,'hippo') or jcr:contains(@myproject:title,'hippo'))]}]/

It's also possible to specify ordering in the XPath query. When specified, it overrides the sorting configured in the faceted tree. For example:

/content/document/myproject/faceted-news[{xpath(//*[jcr:contains(.,'hippo')] order by @myproject:date descending)}]/
Although it's possible to specify range queries using XPath, they are CPU-intensive and slow. It is recommended to configure facet value ranges in the faceted tree if possible.

 

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?