import type { QueryDSL, SearchOptions, SearchResult, SortOrder, MatchOperator, MultiMatchType, RangeBounds, SortField } from './types.js'; import type { AggregationBuilder } from './aggregation-builder.js'; /** * Fluent query builder for type-safe Elasticsearch queries * * @example * ```typescript * const results = await new QueryBuilder('products') * .match('name', 'laptop') * .range('price', { gte: 100, lte: 1000 }) * .sort('price', 'asc') * .size(20) * .execute(); * ``` */ export declare class QueryBuilder { private index; private queryDSL; private boolClauses; private minimumShouldMatch?; private sortFields; private sourceFields?; private excludeSourceFields?; private resultSize; private resultFrom; private shouldTrackTotalHits; private searchTimeout?; private aggregationBuilder?; private highlightConfig?; constructor(index: string); /** * Create a new query builder instance */ static create(index: string): QueryBuilder; /** * Add a match query */ match(field: string, query: string, options?: { operator?: MatchOperator; fuzziness?: number | 'AUTO'; boost?: number; }): this; /** * Add a match phrase query */ matchPhrase(field: string, query: string, options?: { slop?: number; boost?: number; }): this; /** * Add a multi-match query */ multiMatch(query: string, fields: string[], options?: { type?: MultiMatchType; operator?: MatchOperator; boost?: number; }): this; /** * Add a term query (exact match) */ term(field: string, value: string | number | boolean, boost?: number): this; /** * Add a terms query (match any of the values) */ terms(field: string, values: Array, boost?: number): this; /** * Add a range query */ range(field: string, bounds: RangeBounds, boost?: number): this; /** * Add an exists query (field must exist) */ exists(field: string): this; /** * Add a prefix query */ prefix(field: string, value: string, boost?: number): this; /** * Add a wildcard query */ wildcard(field: string, value: string, boost?: number): this; /** * Add a regexp query */ regexp(field: string, value: string, options?: { flags?: string; boost?: number; }): this; /** * Add a fuzzy query */ fuzzy(field: string, value: string, options?: { fuzziness?: number | 'AUTO'; boost?: number; }): this; /** * Add an IDs query */ ids(values: string[]): this; /** * Add a query string query */ queryString(query: string, options?: { default_field?: string; fields?: string[]; default_operator?: MatchOperator; boost?: number; }): this; /** * Add a simple query string query */ simpleQueryString(query: string, options?: { fields?: string[]; default_operator?: MatchOperator; boost?: number; }): this; /** * Match all documents */ matchAll(boost?: number): this; /** * Add a custom query to the must clause */ must(query: QueryDSL): this; /** * Add a custom query to the should clause */ should(query: QueryDSL): this; /** * Add a custom query to the must_not clause */ mustNot(query: QueryDSL): this; /** * Add a custom query to the filter clause */ filter(query: QueryDSL): this; /** * Set minimum_should_match for boolean queries */ minimumMatch(value: number | string): this; /** * Set a custom query DSL (replaces builder queries) */ customQuery(query: QueryDSL): this; /** * Add sorting */ sort(field: string, order?: SortOrder): this; /** * Add custom sort configuration */ customSort(sort: SortField | string): this; /** * Specify fields to include in results (source filtering) */ fields(fields: string[]): this; /** * Specify fields to exclude from results */ exclude(fields: string[]): this; /** * Set number of results to return */ size(size: number): this; /** * Set offset for pagination */ from(from: number): this; /** * Set pagination (convenience method) */ paginate(page: number, pageSize: number): this; /** * Set whether to track total hits */ trackTotalHits(track: boolean | number): this; /** * Set search timeout */ timeout(timeout: string): this; /** * Configure highlighting */ highlight(config: SearchOptions['highlight']): this; /** * Get aggregation builder */ aggregations(configure: (builder: AggregationBuilder) => void): this; /** * Build the final query DSL */ build(): SearchOptions; /** * Execute the query and return results */ execute(): Promise>; /** * Execute query and return only the hits */ executeAndGetHits(): Promise['hits']['hits']>; /** * Execute query and return only the source documents */ executeAndGetSources(): Promise; /** * Count documents matching the query */ count(): Promise; } /** * Create a new query builder instance */ export declare function createQuery(index: string): QueryBuilder;