<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div>
<h2>How to define available aggregations for fields of a certain type</h2>
<p>
In Flexmonster, it's possible to define available aggregations for all
fields of a <code>"number"</code>, <code>"string"</code>,
<code>"date string"</code>, or <code>"time"</code> type. This feature is
supported for JSON, CSV, and the custom data source API.
</p>
<p>
For the custom data source API, aggregations for fields of a certain type
should be defined in a response to the /fields request.
<a
href="https://www.flexmonster.com/api/fields-request/#aggregations"
target="_blank"
>Learn more in our documentation</a>.
</p>
<p>
For JSON and CSV, we define aggregations for fields of a certain type using
the <code>mapping.aggregations.[field_type]</code> property. In the below
example, the following aggregations are defined:
</p>
<ul>
<li>
<code>"sum"</code> and <code>"average"</code> aggregations for number
fields.
</li>
<li>
<code>"max"</code> and <code>"min"</code> aggregations for date fields.
</li>
<li>
<code>"count"</code> and <code>"distinctcount"</code> aggregations for
string fields.
</li>
</ul>
<p>
<a
href="https://www.flexmonster.com/doc/mapping/#aggregations-for-field-types"
target="_blank"
>Visit our docs to learn more about this feature</a>.
</p>
</div>
<div id="pivot-container"></div>