import type { AggregationDSL, QueryDSL, SortOrder, SortField } from './types.js'; /** * Fluent aggregation builder for type-safe Elasticsearch aggregations * * @example * ```typescript * const query = new QueryBuilder('products') * .aggregations((agg) => { * agg.terms('categories', 'category.keyword', { size: 10 }) * .subAggregation('avg_price', (sub) => sub.avg('price')); * }); * ``` */ export declare class AggregationBuilder { private aggregations; private currentAggName?; /** * Add a terms aggregation */ terms(name: string, field: string, options?: { size?: number; order?: Record; missing?: string | number; }): this; /** * Add an average metric aggregation */ avg(name: string, field: string, missing?: number): this; /** * Add a sum metric aggregation */ sum(name: string, field: string, missing?: number): this; /** * Add a min metric aggregation */ min(name: string, field: string, missing?: number): this; /** * Add a max metric aggregation */ max(name: string, field: string, missing?: number): this; /** * Add a cardinality metric aggregation */ cardinality(name: string, field: string): this; /** * Add a stats aggregation */ stats(name: string, field: string): this; /** * Add an extended stats aggregation */ extendedStats(name: string, field: string): this; /** * Add a percentiles aggregation */ percentiles(name: string, field: string, percents?: number[]): this; /** * Add a date histogram aggregation */ dateHistogram(name: string, field: string, options: { calendar_interval?: string; fixed_interval?: string; format?: string; time_zone?: string; min_doc_count?: number; }): this; /** * Add a histogram aggregation */ histogram(name: string, field: string, interval: number, options?: { min_doc_count?: number; }): this; /** * Add a range aggregation */ range(name: string, field: string, ranges: Array<{ from?: number; to?: number; key?: string; }>): this; /** * Add a filter aggregation */ filterAgg(name: string, filter: QueryDSL): this; /** * Add a top hits aggregation */ topHits(name: string, options?: { size?: number; sort?: Array; _source?: boolean | { includes?: string[]; excludes?: string[]; }; }): this; /** * Add a sub-aggregation to the last defined aggregation */ subAggregation(_name: string, configure: (builder: AggregationBuilder) => void): this; /** * Add a custom aggregation DSL */ custom(name: string, aggregation: AggregationDSL): this; /** * Build the aggregations object */ build(): Record; } /** * Create a new aggregation builder */ export declare function createAggregationBuilder(): AggregationBuilder;