Facets

Dynamicweb 9 features a lightning fast generalized search framework usually referred to as New Indexing, which can be used to index and search through all kinds of data on your solution – productscontentusers, etc.

Broadly speaking, New Indexing consists of the following elements:

  • Indexes – which are data structures optimized for data retrieval
  • Queries – which are used to retrieve data based on criteria you define
  • Facets – which are used to create filters in frontend
  • Tasks – which are used to rebuild indexes at an interval

All of these elements can be heavily configured to suit your particular scenario – and all exist within a so-called repository, which is simply a folder in the file archive containing configuration files.

This article will tell you more about Facets.

Facets are a particular kind of filter which allows customers to refine a product list based on values in the index (Figure 2.1).

Figure 2.1 Frontend example of how facets work

Technically, a facet is a mapping between a query parameter (e.g. Manufacturer) and a list of values from a field in the index (e.g. Manufacturer name) – selecting one of the values then passes the value to the query, and the filtered query result is then returned to frontend.

Facets are created inside facet groups.

To create a facet group:

  • Click Add Facets in the repository toolbar to create a facet group
  • Name it
  • Select a Query to pass the facet values to

This opens the facet group configuration view (Figure 2.2).

Figure 2.2 Creating a facet group

From the facet group configuration view, you can add three types of facet:

  • A field facet retrieves a list of all possible values found in a particular field in the index
  • A list facet lets you group field values under a common label (“Spring colors”)
  • A term facet is identical to a field facet, but will only retrieve the 2048 most frequently used field options from a field

In general, we don’t recommend faceting on data which requires you to use a term facet, as too many facet options can impact performance.

All three facet types can calculate the count of matching elements in the entire query result sat for each facet option.

On each facet you can specify a render type - this is simply a string value available when rendering facets in frontend, which makes it possible to render several types of facet controls within a single facets loop.

 

Field facets retrieve facet options from a particular field in the index – so if the field Colors has twelve different values (blue, green, red, mauve, etc.), twelve different facet options will be available in frontend.

To create a field facet:

  • Click Add field facet on the facet group page
  • Provide a facet name
  • Select a field to retrieve facet options from (fields with more than 2048 different terms cannot be selected - use a term facet instead)
  • Select a query parameter to pass the option values to
  • Specify a render type
Figure 3.1 Creating field facets

A list facet allows you to manually specify list options and give them custom labels (Figure 4.1).

  • Click Add list facet on the facet group page
  • Provide a facet name
  • Select a field to retrieve facet options from
  • Select a query parameter to pass the option values to
  • Specify a render type
  • Create a number of labels and values
Figure 4.1 Creating list facets

If multiple options are given the same label, they will be grouped together – which means that you can use list facets to group facet options under a particular label.

Please note that there is no built-in validation, the values you enter must fit the source data or the facet option will appear empty in frontend.

A term facet behaves almost identical to a field facet, except for the fact that it will only retrieve the 2048 most frequent terms from a field. This makes it possible to facet on fields with a lot of variance in terms, without crippling performance completely.

To create a term facet:

  • Click Add field facet on the facet group page
  • Provide a facet name
  • Select a field to retrieve facet options from
  • Select a query parameter to pass the option values to
  • Specify a render type
Figure 5.1 Creating term facets