Represents one facet (a filterable, aggregated dimension) of a report or a faceted admin listing, such as reward, tag, organisation or group, together with the buckets of counts computed for it. A report implementing FacetsReport, or an Elasticsearch-backed folder such as OrganisationsFolderES or AdminApp's user listing, builds one Facet per dimension, populates it with TermFacetBucket entries from the aggregation results, and exposes the list for a report page or a filterable listing. The static helper methods on this class extract facet filter parameters from the current request and test whether a candidate entity or key matches the filter text a user has typed for a facet.
Properties
| Property | Returns | Description |
|---|---|---|
| buckets | List<FacetBucket> | The buckets computed for this facet so far, in the order they were added. Never null; empty until buckets have been added with addTermBucket. |
| filter | String | The raw filter text currently applied to this facet, as typed by the user. Never null; returns an empty string when no filter is set. |
| filterProvided | boolean | Whether the current request explicitly supplied a filter value for this facet, as opposed to isNoFilter, which states whether the facet is configured to never accept one. |
| name | String | The facet's name, used as the aggregation key and as the request parameter name for its filter value. |
| noFilter | boolean | Whether this facet is configured to never accept a filter, regardless of any filter value present in the request. This is distinct from isFilterProvided, which reflects what the current request actually supplied. |
| title | String | The facet's display title, shown as the heading for this facet's filter and bucket list. |
Methods
getName()
Returns: String
The facet's name, used as the aggregation key and as the request parameter name for its filter value.
getTitle()
Returns: String
The facet's display title, shown as the heading for this facet's filter and bucket list.
getFilter()
Returns: String
The raw filter text currently applied to this facet, as typed by the user. Never null; returns an empty string when no filter is set.
isFilterProvided()
Returns: boolean
Whether the current request explicitly supplied a filter value for this facet, as opposed to isNoFilter, which states whether the facet is configured to never accept one.
maxAggs(int defaultMax)
Returns: int
Works out how many aggregation buckets to request for this facet. When a filter has been provided a much higher cap is used, since the filter is applied to the full bucket set to find matches rather than just the top few.
| Parameter | Description |
|---|---|
defaultMax | the bucket limit to use when no filter has been provided |
getBuckets()
Returns: List<FacetBucket>
The buckets computed for this facet so far, in the order they were added. Never null; empty until buckets have been added with addTermBucket.
addTermBucket(String name, String title, long count)
Returns: TermFacetBucket
Creates a term bucket for this facet, using the facet's own name as the bucket's aggregation name, and adds it to this facet's bucket list.
| Parameter | Description |
|---|---|
name | the term value this bucket represents, typically an aggregation key or entity id |
title | the display title for this term |
count | the number of documents matching this term |
isNoFilter()
Returns: boolean
Whether this facet is configured to never accept a filter, regardless of any filter value present in the request. This is distinct from isFilterProvided, which reflects what the current request actually supplied.