Apache Jackrabbit does not yet provide out-of-the-box faceting support. In order to provide this functionality for our users, the Jahia team looked for ways to integrate Apache Solr - one of the most popular Apache Lucene based open source solutions offering faceting support - into Jackrabbit. This turned out to be a difficult endeavor as Solr was not designed to easily be integrated with other frameworks, in particular to work with indices that were not created with Solr. We nevertheless were able to implement a solution, in the form of the
SimpleJahiaJcrFacets class, to bridge Jackrabbit and Solr.
SimpleJahiaJcrFacets is very similar to Solr's
SimpleFacets class and reuses classes from solr-common to work with exactly the same facet query syntax and result objects as Solr does. It is therefore highly recommended to learn more about Solr faceting to work efficiently with facets in Jahia Digital Factory.
Support for faceting in Jahia Digital Factory is provided by the
Facets module. It is therefore important to activate the module for your site if you intend to use facets.
Configuring properties for faceting
Node properties that are used for faceting will, in most cases, require a second indexing, different from the normal one, to support faceting. This is needed because analyzers usually perform stemming, lowercasing and tokenizing before indexing a field. However, in order for a value to be useful for faceting, it:
- should not be tokenized into separate words
- should not be lowercased
- should not have punctuation removed
- should not be stored in the index
Jahia extended the Compact Node Definition (CND) format to make it possible to easily specify that a given property should be used for faceting. This is accomplished by adding the
facetable attribute to the property you want to mark for faceting indexing. Below is an example, where the
eventsType properties are marked as
facetable and will therefore be indexed specifically for faceting (in addition to the regularly performed indexing):
[jnt:event] > jnt:content, jmix:editorialContent, mix:title, jmix:structuredContent - startDate (date) facetable - endDate (date) facetable - location (string) i18n facetable - eventsType (string, choicelist[resourceBundle]) facetable < meeting,consumerShow,roadShow,conference,show,pressConference - body (string, richtext) i18n
facetableafter content has already been created for that particular nodetype, you will need to rebuild the indices as explained in the Rebuild indices section.
Facetable fields are prefixed by
FACET: in the index.
Jahia 6.6.1 added support for hierarchical field value faceting. Hierarchical faceting, as its name implies, means that facets can leverage existing hierarchy in the data to offer more intuitive filtering. Using hierarchical faceting, you can filter your data to see items at a specific hierarchical level along with all of their children. For example, when you filter on a specific category, you will not only get nodes categorized with exactly this category but also nodes categorized with any of its children category.
Marking a property as being a target for hierarchical faceting is as easy as using the
hierarchical attribute for this property in the associated nodetype definition. Here is how this is done for the
jmix:categorized mixin containing the hierarchical facetable field
[jmix:categorized] mixin extends = nt:hierarchyNode, jnt:content, jnt:page itemtype = classification - j:defaultCategory (weakreference, category[autoSelectParent=false]) facetable hierarchical multiple
j:defaultCategoryas, up to version 6.6.1, only counts for real assignements were displayed. The behavior since 6.6.1 now takes into account the parents of the assigned category for the facet count. If you'd rather revert to the previous behavior, you could remove the hierarchical attribute on
j:defaultCategoryor distinguish between hierarchical and non-hierarchical categories with a second category property.
As Jahia Digital Factory leverages Apache Solr for faceting, it supports all the facet types (field, date, range, queries) available in Apache Solr. See Facet types and their parameters to get a description of all supported facet types and parameters.
Jahia not only offers backend access to run facet queries, but also provides a facet module with several components to help in creating templates using faceting support simply with drag and drop in the Studio.