Displaying facets

Last updated on
30 April 2025

Introduction

In XC Drupal Toolkit we introduced use following hierarchy of terms, since we found, that the term 'facet' is not clear. The faceted navigation is displayed in a block, called XC facets When you install the XC modules, you should place the XC facets block somewhere. The block contains a group of facet fields, and each fields contains several terms. In Solr there could be multiple facet types: field, date and query. Each types involve different parameters. In the administrator form you can add default parameters for each types, and you can use specific parameters for any fields. For example the default settings for field-based facet is, that each facet fields should contain five terms, but you can specify that the (imaginary) author field should contain ten terms. We call these parameter sets as properties. The best way, that you first set up several typical properties, then use them when you create facet group, and adds facet fields to the group. The properties are reusable, so you can use same parameters in different facet groups, and different facet fields.

Let's see the following example:

 (-) search term #1
 (-) search term #2

 facet group
 |
 o- authors (facet field #1)
 |   |
 |   o- term #1
 |   o- term #2
 |   o- term #N (N = 5)
 |
 o- subjects (facet field #2)
 |   |
 |   o- term #1
 |   o- term #2
 |   o- term #N (N = 10)
 |
 o- publication dates (facet field #3)
     |
     o- term #1
     o- term #2
     o- term #N

Here we defined 3 facet fields. The navigation bar contains 5 authors and 10 subjects, since their field facet properties are different.

You can link a facet group to a search user interface.

Field based facets

The field based facets displays the content of Solr fields, while date and query based facets displays some kind of derivatives. If you want to use a field as field based facet, you should index it as 'phrase'. When you create facet fields on the indexing admin page, you do not worry about it, the Drupal Toolkit will automatically stores those fields in the proper format.

The properties you can set up for a field-based facet:

name
Display name of the attribute set.
description
Longer text describing the purpose of this facet property set.
prefix
Limits the terms on which to facet to those starting with the given string prefix.
Sort
This param determines the ordering of the facet field constraints. count or index.
Limitation
The size of the facet (how many terms included). Negative number means unlimited.
Offset
The offset of the first element. When we would like to paginate the terms, we should set an offset value for every pages except the first.
Mincount
The minimum number of items in facet (default is 0).
Missing
Sets whether Solr show the number of docs which miss the facet.
Method
Choose the method used in facet calculation (enum: count on all documents, fc: on documents in cache (default value)).

date based facets

The date based facets - unlike the field based facets - do not show the actual field values, but the numbers of documents which has date field values between date ranges. You can set up the first and the last dates, and an interval (gap). The interval has its own syntax, which you can find here: http://lucene.apache.org/solr/api/org/apache/solr/util/DateMathParser.html. Later we would like to hide this syntax, and let the user use verbose dropdown selectors.

The properties of the date based facets:

name
Display name of the attribute set.
description
Longer text describing the purpose of this facet property set.
Start
Starting date.
End
Ending date.
Gap
Interval between two dates.
Hardend
The last gap can override the end date.
Other
Other date values to compute (possible: before, after, between, none, all.

Help improve this page

Page status: Not set

You can: