# Configuring aggregated records in a data source

Aggregated records allow you to group records by dimension or property values.

By configuring aggregated records, you enable the MDEX Engine to handle a group of multiple records as though it were a single record, based on the value of the rollup key. A rollup key can be any property or dimension that has its rollup attribute enabled.

You can use parent-child data source relationships to create multiple data sources with different aggregations. The parent data source can use base records, while multiple child data sources each aggregate by a different rollup key.

For details on how individual components handles record aggregation, see the Discovery Framework Component Catalog.

Note: Aggregated records in the Discovery Framework are subject to the same constraints as they are in the MDEX Engine: you cannot control the order of base records within an aggregate, and you cannot control which record is used as the representative record (beyond controlling overall sort order).

## Aggregated record configuration

To configure a data source for aggregated records, you include the RecordAggregator QueryFunction class in the data source's JSON configuration file. The RecordAggregator contains two configuration properties:rollupKey and aggCount.

The rollupKey property is used to specify the dimension or property by which records in a navigation object's record list should be aggregated.

The aggCount property is used to limit the number of base records returned with the aggregated record. There are three possible values for aggCount:

- `ZERO_ERECS_PER_AGGR`: none of the records that compose the aggregated record will be returned. (In most cases, `ZERO_ERECS_PER_AGGR` is not useful. Because the MDEX Engine returns zero records, your components have almost no data to work with.)
- `ONE_EREC_PER_AGGR`: one of the records that composes the aggregated record will be returned.
- `ALL_ERECS_PER_AGGR` : all of the records that compose the aggregated record will be returned. (Due to performance implications, use of `ALL_ERECS_PER_AGGR` is discouraged.)

If no aggCount value is set, the default is `ONE_EREC_PER_AGGR`.

## Aggregated record example

In the following example data source configuration file, the P_Winery property is the rollup key, and one of the records that composes the aggregated record will be returned.

    {
    	"server":"server01.lab.acme.com",
    	"port":"15000",
    		"baseFunctions": [
    		{"class":"com.endeca.portal.data.functions.RecordAggregator",
    		 "rollupKey":"P_Winery",
    		 "aggCount":"ONE_EREC_PER_AGGR"
    		}
    	]
    }