You can define an aggregation by:
For example, if you have a facet based on the "country" of a sale, you can add an
aggregation, on the price * quantity
expression, using the "SUM" aggregation
function. For each country, you get the total revenue generated by the sales on this country.
Table 1. Available Aggregation Functions for Facets
Function
|
Description
|
MIN
|
The minimum value of the expression for all documents in the facet value.
|
MAX
|
The maximum value the expression for all documents in the facet value.
|
SUM
|
The total of all values of the expression over all documents in the facet value.
|
AVG
|
The average value of the expression over all documents in the facet value.
|
STDDEV
|
The standard deviation of all values of the expression for all documents in the
facet value.
|
CENTILE(x)
|
Computes Nth percentile of the expression for all documents in the facet value,
where N is a double between 0.0 and 100.0.
|
COUNT
|
The count of all documents that contain a value for the expression set in the facet
value. Note:
Do not confuse it with the category document count.
|
MAXDATE
|
Computes the max date based on index time. You can specify output format in a
custom expression using date formats (see Which Facet Type Should I Use?).
|
MINDATE
|
Computes the min date based on index time. You can specify output format in a
custom expression using date formats (see Which Facet Type Should I Use?).
|
Most Mashup UI widgets that display facets can use aggregations, instead of the simple count of the
facet value.
The results of aggregation functions on NULL values in the Search API follows these
conventions:
-
max(empty) =
empty (that is, no value)
-
avg(empty) =
empty (that is, no value)
-
sum(empty) =
empty (that is, no value)
These values are returned as follows in the Access API (no values for unvalued aggregations):
<exa:facet id="Language" path="Top/language" data="" description="Language" count="2"
refinable="true" refinementPolicy="exclusive" type="category" nbClippedCategories="0" totalClippedCategories="0">
<exa:facetInfo key="sort" value="count"/>
<exa:facetInfo key="reverse" value="false"/>
<exa:facetInfo key="hasRefine" value="false"/>
<exa:aggregation id="mini" type="LONG"/>
<exa:aggregation id="moyen" type="LONG"/>
<exa:aggregation id="maxi" type="LONG"/>
<exa:category id="f/Language/fr" path="Top/language/fr" data="" description="fr" count="2" score="0"
state="DISPLAYED" nbClippedChildren="0">
<exa:aggregation id="mini" type="LONG"/>
<exa:aggregation id="moyen" type="LONG"/>
<exa:aggregation id="maxi" type="LONG"/>
</exa:category>
</exa:facet>