Plugin faceted navigation interface

Introduction

Faceted navigation can be configured as part a plugin. This allows a plugin to define faceted navigation to support the other functionality provided as part of the plugin. For example you may wish to write a plugin to gather content from a new type of social media and include some default facets to display in the user interface.

Interface methods

To provide faceted navigation configuration, you will need to implement the FacetProvider interface.

The FacetProvider interface has a single method:

String extraFacetedNavigation(IndexConfigProviderContext context)

Since facets are defined at a results page level, the IndexConfigProviderContext provides both a collection (parent search package ID) and profile (results page ID), and extraFacetedNavigation will be run for every results page.

Additional facets can be supplied by returning a JSON similar to the API.

GET /faceted-navigation/v2/collections/{collection}/profiles/{profile}/facet/{id}/views/{view}

This expects to return a list [] of Facets. The id, lastModified and created fields do not need to be set.

When building a plugin configure the faceted navigation using the faceted navigation configuration screen in the administration interface. After configuring your facets, copy the JSON from the facet configuration JSON tab on the preview screen for the facet and omit the id, lastModified and created fields.

For example:

[{
"name": "Authors",
"facetValues": "FROM_SCOPED_QUERY_HIDE_UNSELECTED_PARENT_VALUES",
"constraintJoin": "AND",
"selectionType": "SINGLE",
"categories": [{ "type": "MetaDataFieldCategory", "subCategories": [], "metadataField": "author" }],
"order": [ "SELECTED_FIRST", "COUNT_DESCENDING"]
}]
Facet names must be unique within the results page. Facets defined for a results page will be used in preference to facets defined from the plugin if both define a facet with the same name.

Usage

Facets will automatically start appearing in search results after the plugin is enabled on the results page.

Some facets will require a reindex to take effect.

Logging

Log messages from the extraFacetedNavigation method will appear in the search package’s user interface logs.

© 2015- Squiz Pty Ltd