Nuxeo Server

How to Configure a Search Filter With Facets and Other Aggregates

Updated: March 18, 2024

Aggregation is a function where the data are grouped together according to certain criteria to form a single value of more significant meaning or measurement. Aggregates work as a data analytics tools by building analytic information over a set of documents. One of the most known aggregate is the Term Aggregate as known as facet.

Before you start using aggregates you may want to take a look to the document about the different type of aggregates supported and the Page Provider.

Nuxeo Platform supports six different types of aggregates: Terms, Significant Terms, Range, Date Range, Histogram and Date Histogram. This how-to will help you to understand how to use them.

For more information about aggregates, see the Elasticsearch Documentation about Aggregation

This how-to aims at showing you how to use the different types of aggregates available in Nuxeo Platform with a Contract document type. This how-to will guide you through the different steps of this process:

  • Create a contract document type
  • Create a new search content view

Prerequisites

Before starting this how-to you will need to create the following elements in Studio:

  • A Contract document type with 4 metadata: ContractNumber, OperationalHealthRating, RPMNumbers and SCDRelationshipHealthRating.

    See the how-to How to Define a Document Type for more detailed steps.

  • A simple vocabulary Rating assigned to the OperationalHealthRating and SCDRelationshipHealthRating elements:

    For more details on vocabularies, see the Directory and Vocabulary How-tos.

You should end up with something like this:

Creating a New Search Content View with Aggregates

  1. Go to Listing and Views > Content Views.
  2. Create a new content view called Contracts.
  3. Fill in the Query & form page like this:

Now that you have created your content view, you can customize it by adding different types of widgets and aggregates depending on your needs in the Search Layout part of the page.

Full Text Widget

This widget allows you to do a full-text search on a particular field of a document.

  1. Drag and drop a Container widget from the right to the grid.
  2. Edit the container:

    Studio LabelContainer Contract Number
    LabelContract Number
    Handle LabelYes
    DisplayBlock (Label on top)
  3. Click on , drag and drop the Contract Number widget from the right to the grid and edit it:

    Studio LabelContract Number
    LabelContract Number
    Hide LabelYes
  4. Click on Save.

  5. Click on Go back to previous page.

Terms Aggregate

The Terms aggregate works with text properties like vocabularies, here we work with the vocabulary Rating created at the beginning.

  1. Drag and drop a Container widget from the right to the grid.

    Studio LabelContainer Operational Health Rating
    LabelOperational Health Rating
    Handle LabelYes
    DisplayBlock (Label on top)
  2. Click on , drag and drop the Terms aggregate from the right to the grid.

  3. Select Contract > OperationalHealthRating > Ok.

  4. Fill the Layout widget Editor:

    Studio LabelTerms
    LabelOperational Health Rating
    Hide LabelYes
    Widget TypeDirectory Checkbox
    VocabularyRating
    LayoutPage direction
  5. Click on Save.

  6. Click on Go back to previous page.

Significant Terms Aggregate

This aggregate returns significant occurrences of terms in a set, not just the most used ones. A term is judged "significant" if there is a noticeable difference in the frequency in which a term appears in the subset and in the background.

  1. Drag and drop a Container widget from the right to the grid.
  2. Edit the container:

    Studio LabelContainer Significant Terms
    LabelSignificant Terms
    Handle LabelYes
    DisplayBlock (Label on top)
  3. Click on , drag and drop the Significant Terms aggregate from the right to the grid.

  4. Select dublincore > Source and click on OK.

  5. Fill the Layout widget Editor:

    Studio LabelSignificant Terms
    LabelSignificant Terms
    Hide LabelYes
    Widget TypeCheckbox
    LayoutPage direction
  6. Click on Save.

  7. Click on Go back to previous page.

Date Range Aggregate

This aggregate is dedicated to date values. It allows you to see the documents created over a certain period of time. Note that the "From" values are included and the "To" values are excluded for each range defined.

  1. Drag and drop a Container widget from the right to the grid.
  2. Edit the container:

    Studio LabelContainer Creation Date
    LabelCreation Date
    Handle LabelYes
    DisplayBlock (Label on top)
  3. Click on , drag and drop the Date Range aggregate from the right to the grid.

  4. Select dublincore > Created and click on OK.

  5. Fill the Layout widget Editor:

    Studio LabelCreation Date
    LabelCreation Date
    Hide LabelYes
    Date Ranges
    • Label: Last year From: now-1y To: now-1M
    • Label: Last month From: now-1M To: now-7d
    • Label: Last week From: now-7d To: now-24H
    • Label: Last 24h From: now-24H To: now
    Widget TypeDate Range Checkbox
    LayoutPage direction
  6. Click on Save.

  7. Click on Go back to previous page.

Range Aggregate

This aggregate allows you to define a set of ranges and works as the date range aggregate. You can, for example, create range with price, ages etc. Here we will range by RPM Numbers.

  1. Drag and drop a Container widget from the right to the grid.
  2. Edit the container:

    Studio LabelContainer RPM Numbers
    LabelRPM Numbers
    Handle LabelYes
    DisplayBlock (Label on top)
  3. Click on , drag and drop the Range aggregate from the right to the grid.

  4. Select Contract > RPMNumbers and click on OK.

  5. Fill the Layout widget Editor:

    Studio LabelRPM Numbers
    LabelRPM Numbers
    Hide LabelYes
    Ranges
    • Label: Less than 10 From: 0 To: 10
    • Label: Between 11 and 100 From: 11 To: 100
    • Label: More than 100 From: 101 To: 100,000
    Widget TypeRange Checkbox
    LayoutPage direction
  6. Click on Save.

  7. Click on Go back to previous page.

Deploying Changes on Your Nuxeo Platform Instance

  1. Go to your Nuxeo Platform instance,
  2. Connect as Administrator with Administrator password,
  3. Click on Admin Center > Update Center > Nuxeo Studio,
  4. Click on the Update button,
  5. Go in a workspace and create a new Contract.