Skip to main content
Version: 11.14.0

Aggregations

The Aggregations module provides a function to fetch updated aggregation data for a specific facet based on the current query. This is useful for refreshing a single aggregation independently of the full query execution.

Functions

fetchAggregation()

Fetches the current state of an aggregation for the given query.

Parameters

ParameterTypeRequiredDescription
aggregationAggregationThe aggregation to refresh
queryQueryThe current query context
auditAuditEventsAudit events to record with the request

Returns Promise<Aggregation> — the refreshed aggregation.

Example

fetch-aggregation.ts
import { fetchAggregation } from '@sinequa/atomic';

const aggregation = {
name: 'Modified',
isTree: false,
items: []
};

const query = {
name: '_query',
text: 'tesla'
};

const result = await fetchAggregation(aggregation, query, {
type: 'Search_Text',
detail: { querytext: query.text }
});

console.log('Aggregation items:', result.items);