elasticlink 0.8.0-beta → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +631 -819
- package/dist/index.cjs +1528 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1890 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +1889 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1474 -18
- package/dist/index.js.map +1 -0
- package/package.json +25 -19
- package/dist/aggregation.builder.d.ts +0 -6
- package/dist/aggregation.builder.d.ts.map +0 -1
- package/dist/aggregation.builder.js +0 -64
- package/dist/aggregation.types.d.ts +0 -173
- package/dist/aggregation.types.d.ts.map +0 -1
- package/dist/aggregation.types.js +0 -6
- package/dist/bulk.builder.d.ts +0 -28
- package/dist/bulk.builder.d.ts.map +0 -1
- package/dist/bulk.builder.js +0 -51
- package/dist/bulk.types.d.ts +0 -46
- package/dist/bulk.types.d.ts.map +0 -1
- package/dist/bulk.types.js +0 -6
- package/dist/field.helpers.d.ts +0 -167
- package/dist/field.helpers.d.ts.map +0 -1
- package/dist/field.helpers.js +0 -282
- package/dist/field.types.d.ts +0 -255
- package/dist/field.types.d.ts.map +0 -1
- package/dist/field.types.js +0 -6
- package/dist/index-management.builder.d.ts +0 -33
- package/dist/index-management.builder.d.ts.map +0 -1
- package/dist/index-management.builder.js +0 -64
- package/dist/index-management.types.d.ts +0 -126
- package/dist/index-management.types.d.ts.map +0 -1
- package/dist/index-management.types.js +0 -6
- package/dist/mapping.builder.d.ts +0 -46
- package/dist/mapping.builder.d.ts.map +0 -1
- package/dist/mapping.builder.js +0 -39
- package/dist/mapping.types.d.ts +0 -160
- package/dist/mapping.types.d.ts.map +0 -1
- package/dist/mapping.types.js +0 -6
- package/dist/multi-search.builder.d.ts +0 -22
- package/dist/multi-search.builder.d.ts.map +0 -1
- package/dist/multi-search.builder.js +0 -39
- package/dist/multi-search.types.d.ts +0 -36
- package/dist/multi-search.types.d.ts.map +0 -1
- package/dist/multi-search.types.js +0 -6
- package/dist/query.builder.d.ts +0 -4
- package/dist/query.builder.d.ts.map +0 -1
- package/dist/query.builder.js +0 -264
- package/dist/query.types.d.ts +0 -324
- package/dist/query.types.d.ts.map +0 -1
- package/dist/query.types.js +0 -7
- package/dist/settings.presets.d.ts +0 -98
- package/dist/settings.presets.d.ts.map +0 -1
- package/dist/settings.presets.js +0 -115
- package/dist/suggester.builder.d.ts +0 -23
- package/dist/suggester.builder.d.ts.map +0 -1
- package/dist/suggester.builder.js +0 -51
- package/dist/suggester.types.d.ts +0 -50
- package/dist/suggester.types.d.ts.map +0 -1
- package/dist/suggester.types.js +0 -6
- package/dist/vector.types.d.ts +0 -17
- package/dist/vector.types.d.ts.map +0 -1
- package/dist/vector.types.js +0 -6
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1890 @@
|
|
|
1
|
+
import { AggregationsAutoDateHistogramAggregation, AggregationsAverageAggregation, AggregationsBucketScriptAggregation, AggregationsBucketSelectorAggregation, AggregationsCardinalityAggregation, AggregationsCompositeAggregation, AggregationsCompositeAggregationSource, AggregationsCumulativeSumAggregation, AggregationsDateHistogramAggregation, AggregationsDateRangeAggregation, AggregationsDerivativeAggregation, AggregationsExtendedStatsAggregation, AggregationsFiltersAggregation, AggregationsGeoBoundsAggregation, AggregationsGeoCentroidAggregation, AggregationsGeoDistanceAggregation, AggregationsGeoHashGridAggregation, AggregationsGeoTileGridAggregation, AggregationsHistogramAggregation, AggregationsMaxAggregation, AggregationsMinAggregation, AggregationsMissingAggregation, AggregationsMultiTermsAggregation, AggregationsPercentilesAggregation, AggregationsRangeAggregation, AggregationsRareTermsAggregation, AggregationsSignificantTermsAggregation, AggregationsStatsAggregation, AggregationsSumAggregation, AggregationsTermsAggregation, AggregationsTopHitsAggregation, AggregationsTopMetricsAggregation, AggregationsValueCountAggregation, AggregationsWeightedAverageAggregation, AnalysisAnalyzer, AnalysisCharFilter, AnalysisNormalizer, AnalysisTokenFilter, AnalysisTokenizer, BulkCreateOperation, BulkDeleteOperation, BulkIndexOperation, BulkOperationContainer, BulkOperationContainer as BulkOperationContainer$1, BulkUpdateAction, BulkUpdateOperation, IndicesAlias, IndicesIndexSegmentSort, IndicesIndexSettings, IndicesIndexSettingsAnalysis, IndicesSegmentSortMissing, IndicesSegmentSortMode, KnnSearch, MappingDenseVectorIndexOptions, MappingDynamicTemplate, MappingIndexOptions, MappingRuntimeField, MappingSuggestContext, MsearchMultisearchHeader, MsearchRequest, QueryDslCombinedFieldsQuery, QueryDslConstantScoreQuery, QueryDslDistanceFeatureQuery, QueryDslFieldAndFormat, QueryDslFunctionScoreQuery, QueryDslFuzzyQuery, QueryDslHasChildQuery, QueryDslHasParentQuery, QueryDslIntervalsQuery, QueryDslMatchBoolPrefixQuery, QueryDslMatchPhrasePrefixQuery, QueryDslMatchQuery, QueryDslMoreLikeThisQuery, QueryDslMultiMatchQuery, QueryDslNestedQuery, QueryDslParentIdQuery, QueryDslPercolateQuery, QueryDslQueryContainer, QueryDslQueryStringQuery, QueryDslRankFeatureQuery, QueryDslRegexpQuery, QueryDslScriptQuery, QueryDslScriptScoreQuery, QueryDslSimpleQueryStringQuery, QueryDslSpanNearQuery, QueryDslSpanNotQuery, QueryDslSpanQuery, QueryDslSparseVectorQuery, QueryVectorBuilder, RescoreVector, Script, ScriptField, ScriptSource, SearchCompletionContext, SearchCompletionSuggester, SearchDirectGenerator, SearchHighlightBase, SearchInnerHits, SearchPhraseSuggestCollate, SearchPhraseSuggester, SearchSmoothingModelContainer, SearchTermSuggester, SortResults } from "@elastic/elasticsearch/lib/api/types";
|
|
2
|
+
|
|
3
|
+
//#region src/field.types.d.ts
|
|
4
|
+
/** Options for text fields */
|
|
5
|
+
type TextFieldOptions<MF extends Record<string, FieldMappingWithLiteralType> = Record<string, FieldMappingWithLiteralType>> = {
|
|
6
|
+
analyzer?: string;
|
|
7
|
+
search_analyzer?: string;
|
|
8
|
+
search_quote_analyzer?: string;
|
|
9
|
+
boost?: number;
|
|
10
|
+
index?: boolean;
|
|
11
|
+
store?: boolean;
|
|
12
|
+
doc_values?: boolean;
|
|
13
|
+
similarity?: string;
|
|
14
|
+
fields?: MF;
|
|
15
|
+
copy_to?: string | string[];
|
|
16
|
+
index_options?: MappingIndexOptions;
|
|
17
|
+
index_prefixes?: {
|
|
18
|
+
min_chars?: number;
|
|
19
|
+
max_chars?: number;
|
|
20
|
+
};
|
|
21
|
+
index_phrases?: boolean;
|
|
22
|
+
eager_global_ordinals?: boolean;
|
|
23
|
+
position_increment_gap?: number;
|
|
24
|
+
norms?: boolean;
|
|
25
|
+
term_vector?: 'no' | 'yes' | 'with_positions' | 'with_offsets' | 'with_positions_offsets' | 'with_positions_payloads' | 'with_positions_offsets_payloads';
|
|
26
|
+
};
|
|
27
|
+
/** Options for keyword fields */
|
|
28
|
+
type KeywordFieldOptions<MF extends Record<string, FieldMappingWithLiteralType> = Record<string, FieldMappingWithLiteralType>> = {
|
|
29
|
+
boost?: number;
|
|
30
|
+
index?: boolean;
|
|
31
|
+
store?: boolean;
|
|
32
|
+
doc_values?: boolean;
|
|
33
|
+
similarity?: string;
|
|
34
|
+
normalizer?: string;
|
|
35
|
+
fields?: MF;
|
|
36
|
+
copy_to?: string | string[];
|
|
37
|
+
null_value?: string;
|
|
38
|
+
eager_global_ordinals?: boolean;
|
|
39
|
+
ignore_above?: number;
|
|
40
|
+
split_queries_on_whitespace?: boolean;
|
|
41
|
+
script?: Script | ScriptSource;
|
|
42
|
+
on_script_error?: 'fail' | 'continue';
|
|
43
|
+
};
|
|
44
|
+
/** Options shared by numeric field types (long, integer, short, byte, double, float, half_float) */
|
|
45
|
+
type NumericFieldOptions<MF extends Record<string, FieldMappingWithLiteralType> = Record<string, FieldMappingWithLiteralType>> = {
|
|
46
|
+
boost?: number;
|
|
47
|
+
index?: boolean;
|
|
48
|
+
store?: boolean;
|
|
49
|
+
doc_values?: boolean;
|
|
50
|
+
coerce?: boolean;
|
|
51
|
+
fields?: MF;
|
|
52
|
+
copy_to?: string | string[];
|
|
53
|
+
null_value?: number;
|
|
54
|
+
ignore_malformed?: boolean;
|
|
55
|
+
};
|
|
56
|
+
/** Options for scaled_float (extends numeric with scaling_factor) */
|
|
57
|
+
type ScaledFloatFieldOptions<MF extends Record<string, FieldMappingWithLiteralType> = Record<string, FieldMappingWithLiteralType>> = NumericFieldOptions<MF> & {
|
|
58
|
+
scaling_factor?: number;
|
|
59
|
+
};
|
|
60
|
+
/** Options for unsigned_long fields — null_value accepts string or number for >MAX_SAFE_INTEGER precision */
|
|
61
|
+
type UnsignedLongFieldOptions<MF extends Record<string, FieldMappingWithLiteralType> = Record<string, FieldMappingWithLiteralType>> = Omit<NumericFieldOptions<MF>, 'null_value'> & {
|
|
62
|
+
null_value?: string | number;
|
|
63
|
+
};
|
|
64
|
+
/** Options for date fields */
|
|
65
|
+
type DateFieldOptions<MF extends Record<string, FieldMappingWithLiteralType> = Record<string, FieldMappingWithLiteralType>> = {
|
|
66
|
+
boost?: number;
|
|
67
|
+
format?: string;
|
|
68
|
+
locale?: string;
|
|
69
|
+
index?: boolean;
|
|
70
|
+
store?: boolean;
|
|
71
|
+
doc_values?: boolean;
|
|
72
|
+
fields?: MF;
|
|
73
|
+
copy_to?: string | string[];
|
|
74
|
+
null_value?: string;
|
|
75
|
+
ignore_malformed?: boolean;
|
|
76
|
+
script?: Script | ScriptSource;
|
|
77
|
+
on_script_error?: 'fail' | 'continue';
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Options for date_nanos fields — same API as `date` but stores timestamps at nanosecond precision.
|
|
81
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/date_nanos.html
|
|
82
|
+
*/
|
|
83
|
+
type DateNanosFieldOptions<MF extends Record<string, FieldMappingWithLiteralType> = Record<string, FieldMappingWithLiteralType>> = DateFieldOptions<MF>;
|
|
84
|
+
/** Options for boolean fields */
|
|
85
|
+
type BooleanFieldOptions = {
|
|
86
|
+
boost?: number;
|
|
87
|
+
index?: boolean;
|
|
88
|
+
store?: boolean;
|
|
89
|
+
doc_values?: boolean;
|
|
90
|
+
null_value?: boolean;
|
|
91
|
+
};
|
|
92
|
+
/** Options for dense_vector fields */
|
|
93
|
+
type DenseVectorFieldOptions = {
|
|
94
|
+
dims?: number;
|
|
95
|
+
element_type?: 'float' | 'byte' | 'bit';
|
|
96
|
+
index?: boolean;
|
|
97
|
+
index_options?: MappingDenseVectorIndexOptions;
|
|
98
|
+
similarity?: 'cosine' | 'dot_product' | 'l2_norm' | 'max_inner_product';
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Options for `rank_feature` fields — a single-value numeric feature used to boost relevance.
|
|
102
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rank-feature.html
|
|
103
|
+
*/
|
|
104
|
+
type RankFeatureFieldOptions = {
|
|
105
|
+
positive_score_impact?: boolean;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Options for `rank_features` fields — a sparse map of numeric features used to boost relevance.
|
|
109
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rank-features.html
|
|
110
|
+
*/
|
|
111
|
+
type RankFeaturesFieldOptions = {
|
|
112
|
+
positive_score_impact?: boolean;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Options for semantic_text fields (ES 9.x — ML-powered text field for semantic/hybrid search).
|
|
116
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-text.html
|
|
117
|
+
*/
|
|
118
|
+
type SemanticTextFieldOptions = {
|
|
119
|
+
inference_id?: string;
|
|
120
|
+
search_inference_id?: string;
|
|
121
|
+
model_settings?: {
|
|
122
|
+
task_type?: string;
|
|
123
|
+
[key: string]: unknown;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/** Options for object fields (sub-fields are the first argument) */
|
|
127
|
+
type ObjectFieldOptions = {
|
|
128
|
+
enabled?: boolean;
|
|
129
|
+
dynamic?: boolean | 'strict' | 'runtime';
|
|
130
|
+
};
|
|
131
|
+
/** Options for nested fields (sub-fields are the first argument) */
|
|
132
|
+
type NestedFieldOptions = {
|
|
133
|
+
enabled?: boolean;
|
|
134
|
+
dynamic?: boolean | 'strict' | 'runtime';
|
|
135
|
+
include_in_parent?: boolean;
|
|
136
|
+
include_in_root?: boolean;
|
|
137
|
+
};
|
|
138
|
+
/** Options for completion fields */
|
|
139
|
+
type CompletionFieldOptions = {
|
|
140
|
+
analyzer?: string;
|
|
141
|
+
search_analyzer?: string;
|
|
142
|
+
max_input_length?: number;
|
|
143
|
+
preserve_separators?: boolean;
|
|
144
|
+
preserve_position_increments?: boolean;
|
|
145
|
+
contexts?: MappingSuggestContext[];
|
|
146
|
+
};
|
|
147
|
+
/** Options for geo_point fields */
|
|
148
|
+
type GeoPointFieldOptions = {
|
|
149
|
+
index?: boolean;
|
|
150
|
+
store?: boolean;
|
|
151
|
+
doc_values?: boolean;
|
|
152
|
+
ignore_malformed?: boolean;
|
|
153
|
+
ignore_z_value?: boolean;
|
|
154
|
+
null_value?: string | {
|
|
155
|
+
lat: number;
|
|
156
|
+
lon: number;
|
|
157
|
+
};
|
|
158
|
+
copy_to?: string | string[];
|
|
159
|
+
script?: Script | ScriptSource;
|
|
160
|
+
on_script_error?: 'fail' | 'continue';
|
|
161
|
+
};
|
|
162
|
+
/** Options for geo_shape fields */
|
|
163
|
+
type GeoShapeFieldOptions = {
|
|
164
|
+
index?: boolean;
|
|
165
|
+
store?: boolean;
|
|
166
|
+
doc_values?: boolean;
|
|
167
|
+
orientation?: string;
|
|
168
|
+
ignore_malformed?: boolean;
|
|
169
|
+
};
|
|
170
|
+
/** Options for alias fields */
|
|
171
|
+
type AliasFieldOptions = {
|
|
172
|
+
path: string;
|
|
173
|
+
};
|
|
174
|
+
/** Options for ip fields */
|
|
175
|
+
type IpFieldOptions = {
|
|
176
|
+
boost?: number;
|
|
177
|
+
index?: boolean;
|
|
178
|
+
store?: boolean;
|
|
179
|
+
doc_values?: boolean;
|
|
180
|
+
null_value?: string;
|
|
181
|
+
ignore_malformed?: boolean;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Options for `ip_range` fields — range of IPv4 or IPv6 addresses.
|
|
185
|
+
* Mirrors numeric `RangeFieldOptions` but conceptually scoped to IP ranges.
|
|
186
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/range.html
|
|
187
|
+
*/
|
|
188
|
+
type IpRangeFieldOptions = {
|
|
189
|
+
boost?: number;
|
|
190
|
+
index?: boolean;
|
|
191
|
+
store?: boolean;
|
|
192
|
+
doc_values?: boolean;
|
|
193
|
+
coerce?: boolean;
|
|
194
|
+
};
|
|
195
|
+
/** Options for range fields (integer_range, float_range, long_range, double_range, date_range) */
|
|
196
|
+
type RangeFieldOptions = {
|
|
197
|
+
boost?: number;
|
|
198
|
+
index?: boolean;
|
|
199
|
+
store?: boolean;
|
|
200
|
+
doc_values?: boolean;
|
|
201
|
+
coerce?: boolean;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Options for match_only_text fields.
|
|
205
|
+
* Use when you only need filter/match but not relevance scoring — faster and uses less disk.
|
|
206
|
+
*/
|
|
207
|
+
type MatchOnlyTextFieldOptions<MF extends Record<string, FieldMappingWithLiteralType> = Record<string, FieldMappingWithLiteralType>> = {
|
|
208
|
+
fields?: MF;
|
|
209
|
+
copy_to?: string | string[];
|
|
210
|
+
meta?: Record<string, string>;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Options for search_as_you_type fields.
|
|
214
|
+
* Provides out-of-the-box autocomplete / typeahead capabilities.
|
|
215
|
+
*/
|
|
216
|
+
type SearchAsYouTypeFieldOptions = {
|
|
217
|
+
analyzer?: string;
|
|
218
|
+
search_analyzer?: string;
|
|
219
|
+
search_quote_analyzer?: string;
|
|
220
|
+
max_shingle_size?: 2 | 3 | 4;
|
|
221
|
+
index?: boolean;
|
|
222
|
+
store?: boolean;
|
|
223
|
+
doc_values?: boolean;
|
|
224
|
+
similarity?: string;
|
|
225
|
+
norms?: boolean;
|
|
226
|
+
term_vector?: 'no' | 'yes' | 'with_positions' | 'with_offsets' | 'with_positions_offsets' | 'with_positions_payloads' | 'with_positions_offsets_payloads';
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Options for constant_keyword fields.
|
|
230
|
+
* Every document in the index has the same value for this field.
|
|
231
|
+
* Useful for multi-index queries to identify the index type.
|
|
232
|
+
*/
|
|
233
|
+
type ConstantKeywordFieldOptions = {
|
|
234
|
+
value?: string;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Options for wildcard fields.
|
|
238
|
+
* Optimized for grep-like wildcard/regexp queries on high-cardinality or large fields.
|
|
239
|
+
* Use instead of keyword when leading wildcards (`*foo`) are needed.
|
|
240
|
+
*/
|
|
241
|
+
type WildcardFieldOptions = {
|
|
242
|
+
null_value?: string;
|
|
243
|
+
ignore_above?: number;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Options for flattened fields.
|
|
247
|
+
* Flattens complex/dynamic objects into a single field. Faster than nested,
|
|
248
|
+
* but only supports keyword-level queries on inner values.
|
|
249
|
+
*/
|
|
250
|
+
type FlattenedFieldOptions = {
|
|
251
|
+
depth_limit?: number;
|
|
252
|
+
doc_values?: boolean;
|
|
253
|
+
index?: boolean;
|
|
254
|
+
null_value?: string;
|
|
255
|
+
similarity?: string;
|
|
256
|
+
eager_global_ordinals?: boolean;
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Options for token_count fields — counts the number of tokens in a string.
|
|
260
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/token-count.html
|
|
261
|
+
*/
|
|
262
|
+
type TokenCountFieldOptions = {
|
|
263
|
+
analyzer?: string;
|
|
264
|
+
boost?: number;
|
|
265
|
+
index?: boolean;
|
|
266
|
+
store?: boolean;
|
|
267
|
+
doc_values?: boolean;
|
|
268
|
+
null_value?: number;
|
|
269
|
+
enable_position_increments?: boolean;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Options for join fields — defines parent/child relationships within a single index.
|
|
273
|
+
* `relations` is required and maps parent names to child names.
|
|
274
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html
|
|
275
|
+
*/
|
|
276
|
+
type JoinFieldOptions = {
|
|
277
|
+
relations: Record<string, string | string[]>;
|
|
278
|
+
eager_global_ordinals?: boolean;
|
|
279
|
+
};
|
|
280
|
+
type TypedFieldMapping<T extends string> = Omit<FieldMapping, 'type'> & {
|
|
281
|
+
type: T;
|
|
282
|
+
};
|
|
283
|
+
type FieldMappingWithLiteralType = FieldMapping & {
|
|
284
|
+
type: FieldTypeString;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Typed variant of `NestedFieldMapping` carrying sub-field type info at compile time.
|
|
288
|
+
* Produced when `nested()` is called with a typed field map.
|
|
289
|
+
*/
|
|
290
|
+
type TypedNestedFieldMapping<F extends Record<string, FieldMappingWithLiteralType>> = NestedFieldMapping & Readonly<{
|
|
291
|
+
_subFields: F;
|
|
292
|
+
}>;
|
|
293
|
+
/**
|
|
294
|
+
* Typed variant of `ObjectFieldMapping` carrying sub-field type info at compile time.
|
|
295
|
+
* Produced when `object()` is called with a typed field map.
|
|
296
|
+
*/
|
|
297
|
+
type TypedObjectFieldMapping<F extends Record<string, FieldMappingWithLiteralType>> = ObjectFieldMapping & Readonly<{
|
|
298
|
+
_subFields: F;
|
|
299
|
+
}>;
|
|
300
|
+
type TextFieldMapping = TypedFieldMapping<'text'>;
|
|
301
|
+
type KeywordFieldMapping = TypedFieldMapping<'keyword'>;
|
|
302
|
+
type LongFieldMapping = TypedFieldMapping<'long'>;
|
|
303
|
+
type IntegerFieldMapping = TypedFieldMapping<'integer'>;
|
|
304
|
+
type ShortFieldMapping = TypedFieldMapping<'short'>;
|
|
305
|
+
type ByteFieldMapping = TypedFieldMapping<'byte'>;
|
|
306
|
+
type DoubleFieldMapping = TypedFieldMapping<'double'>;
|
|
307
|
+
type FloatFieldMapping = TypedFieldMapping<'float'>;
|
|
308
|
+
type HalfFloatFieldMapping = TypedFieldMapping<'half_float'>;
|
|
309
|
+
type ScaledFloatFieldMapping = TypedFieldMapping<'scaled_float'>;
|
|
310
|
+
type DateFieldMapping = TypedFieldMapping<'date'>;
|
|
311
|
+
type BooleanFieldMapping = TypedFieldMapping<'boolean'>;
|
|
312
|
+
type BinaryFieldMapping = TypedFieldMapping<'binary'>;
|
|
313
|
+
type IpFieldMapping = TypedFieldMapping<'ip'>;
|
|
314
|
+
type DenseVectorFieldMapping = TypedFieldMapping<'dense_vector'>;
|
|
315
|
+
type SparseVectorFieldMapping = TypedFieldMapping<'sparse_vector'>;
|
|
316
|
+
type RankFeatureFieldMapping = TypedFieldMapping<'rank_feature'>;
|
|
317
|
+
type RankFeaturesFieldMapping = TypedFieldMapping<'rank_features'>;
|
|
318
|
+
type SemanticTextFieldMapping = TypedFieldMapping<'semantic_text'>;
|
|
319
|
+
type UnsignedLongFieldMapping = TypedFieldMapping<'unsigned_long'>;
|
|
320
|
+
type GeoPointFieldMapping = TypedFieldMapping<'geo_point'>;
|
|
321
|
+
type GeoShapeFieldMapping = TypedFieldMapping<'geo_shape'>;
|
|
322
|
+
type CompletionFieldMapping = TypedFieldMapping<'completion'>;
|
|
323
|
+
type NestedFieldMapping = TypedFieldMapping<'nested'>;
|
|
324
|
+
type ObjectFieldMapping = TypedFieldMapping<'object'>;
|
|
325
|
+
type AliasFieldMapping = TypedFieldMapping<'alias'>;
|
|
326
|
+
type PercolatorFieldMapping = TypedFieldMapping<'percolator'>;
|
|
327
|
+
type IntegerRangeFieldMapping = TypedFieldMapping<'integer_range'>;
|
|
328
|
+
type FloatRangeFieldMapping = TypedFieldMapping<'float_range'>;
|
|
329
|
+
type LongRangeFieldMapping = TypedFieldMapping<'long_range'>;
|
|
330
|
+
type DoubleRangeFieldMapping = TypedFieldMapping<'double_range'>;
|
|
331
|
+
type DateRangeFieldMapping = TypedFieldMapping<'date_range'>;
|
|
332
|
+
type IpRangeFieldMapping = TypedFieldMapping<'ip_range'>;
|
|
333
|
+
type DateNanosFieldMapping = TypedFieldMapping<'date_nanos'>;
|
|
334
|
+
type MatchOnlyTextFieldMapping = TypedFieldMapping<'match_only_text'>;
|
|
335
|
+
type SearchAsYouTypeFieldMapping = TypedFieldMapping<'search_as_you_type'>;
|
|
336
|
+
type ConstantKeywordFieldMapping = TypedFieldMapping<'constant_keyword'>;
|
|
337
|
+
type WildcardFieldMapping = TypedFieldMapping<'wildcard'>;
|
|
338
|
+
type FlattenedFieldMapping = TypedFieldMapping<'flattened'>;
|
|
339
|
+
type TokenCountFieldMapping = TypedFieldMapping<'token_count'>;
|
|
340
|
+
type Murmur3FieldMapping = TypedFieldMapping<'murmur3'>;
|
|
341
|
+
type JoinFieldMapping = TypedFieldMapping<'join'>;
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/mapping.types.d.ts
|
|
344
|
+
/**
|
|
345
|
+
* Options for `mappings()`.
|
|
346
|
+
*
|
|
347
|
+
* @param dynamic - Controls how unmapped fields are handled. Defaults to `'strict'`
|
|
348
|
+
* to prevent unmapped fields from being silently indexed. Set to `true` to allow
|
|
349
|
+
* dynamic mapping, or `'runtime'` for runtime fields.
|
|
350
|
+
* @param _source - Configure which fields are stored in `_source`.
|
|
351
|
+
* Use `{ excludes: ['embedding'] }` to prune large dense_vector fields from
|
|
352
|
+
* returned `_source` — they remain searchable via kNN but won't bloat query responses.
|
|
353
|
+
* @param _meta - Custom metadata to attach to the mapping.
|
|
354
|
+
*/
|
|
355
|
+
type MappingOptions = {
|
|
356
|
+
dynamic?: boolean | 'strict' | 'runtime';
|
|
357
|
+
_source?: SourceConfig;
|
|
358
|
+
_meta?: Record<string, unknown>;
|
|
359
|
+
};
|
|
360
|
+
type MappingsSchema<M extends Record<string, FieldTypeString>, F extends Record<string, FieldMappingWithLiteralType> = Record<string, FieldMappingWithLiteralType>> = Readonly<{
|
|
361
|
+
_fieldTypes: M;
|
|
362
|
+
_fields?: F;
|
|
363
|
+
properties: Record<string, FieldMapping>;
|
|
364
|
+
_mappingOptions?: MappingOptions;
|
|
365
|
+
}>;
|
|
366
|
+
type ESTypeToTS = {
|
|
367
|
+
text: string;
|
|
368
|
+
match_only_text: string;
|
|
369
|
+
keyword: string;
|
|
370
|
+
constant_keyword: string;
|
|
371
|
+
wildcard: string;
|
|
372
|
+
long: number;
|
|
373
|
+
integer: number;
|
|
374
|
+
short: number;
|
|
375
|
+
byte: number;
|
|
376
|
+
float: number;
|
|
377
|
+
double: number;
|
|
378
|
+
half_float: number;
|
|
379
|
+
scaled_float: number;
|
|
380
|
+
date: string;
|
|
381
|
+
date_nanos: string;
|
|
382
|
+
boolean: boolean;
|
|
383
|
+
binary: string;
|
|
384
|
+
ip: string;
|
|
385
|
+
geo_point: {
|
|
386
|
+
lat: number;
|
|
387
|
+
lon: number;
|
|
388
|
+
};
|
|
389
|
+
geo_shape: Record<string, unknown>;
|
|
390
|
+
dense_vector: number[];
|
|
391
|
+
sparse_vector: Record<string, number>;
|
|
392
|
+
semantic_text: string;
|
|
393
|
+
unsigned_long: number | string;
|
|
394
|
+
completion: string | {
|
|
395
|
+
input: string[];
|
|
396
|
+
weight?: number;
|
|
397
|
+
};
|
|
398
|
+
search_as_you_type: string;
|
|
399
|
+
nested: unknown;
|
|
400
|
+
object: unknown;
|
|
401
|
+
flattened: Record<string, unknown>;
|
|
402
|
+
alias: unknown;
|
|
403
|
+
percolator: unknown;
|
|
404
|
+
integer_range: {
|
|
405
|
+
gte?: number;
|
|
406
|
+
lte?: number;
|
|
407
|
+
gt?: number;
|
|
408
|
+
lt?: number;
|
|
409
|
+
};
|
|
410
|
+
float_range: {
|
|
411
|
+
gte?: number;
|
|
412
|
+
lte?: number;
|
|
413
|
+
gt?: number;
|
|
414
|
+
lt?: number;
|
|
415
|
+
};
|
|
416
|
+
long_range: {
|
|
417
|
+
gte?: number;
|
|
418
|
+
lte?: number;
|
|
419
|
+
gt?: number;
|
|
420
|
+
lt?: number;
|
|
421
|
+
};
|
|
422
|
+
double_range: {
|
|
423
|
+
gte?: number;
|
|
424
|
+
lte?: number;
|
|
425
|
+
gt?: number;
|
|
426
|
+
lt?: number;
|
|
427
|
+
};
|
|
428
|
+
date_range: {
|
|
429
|
+
gte?: string;
|
|
430
|
+
lte?: string;
|
|
431
|
+
gt?: string;
|
|
432
|
+
lt?: string;
|
|
433
|
+
};
|
|
434
|
+
ip_range: {
|
|
435
|
+
gte?: string;
|
|
436
|
+
lte?: string;
|
|
437
|
+
gt?: string;
|
|
438
|
+
lt?: string;
|
|
439
|
+
} | string;
|
|
440
|
+
token_count: string | number;
|
|
441
|
+
murmur3: string;
|
|
442
|
+
join: string | {
|
|
443
|
+
name: string;
|
|
444
|
+
parent?: string;
|
|
445
|
+
};
|
|
446
|
+
rank_feature: number;
|
|
447
|
+
rank_features: Record<string, number>;
|
|
448
|
+
};
|
|
449
|
+
type InferSubFields<F extends Record<string, FieldMappingWithLiteralType>> = { [K in keyof F]: F[K] extends {
|
|
450
|
+
_subFields: infer Sub extends Record<string, FieldMappingWithLiteralType>;
|
|
451
|
+
} ? F[K] extends {
|
|
452
|
+
type: 'nested';
|
|
453
|
+
} ? Array<InferSubFields<Sub>> : InferSubFields<Sub> : F[K]['type'] extends keyof ESTypeToTS ? ESTypeToTS[F[K]['type']] : unknown };
|
|
454
|
+
type Infer<S> = S extends MappingsSchema<infer _M, infer F> ? InferSubFields<F> : never;
|
|
455
|
+
type FieldsOfType<M extends Record<string, FieldTypeString>, Types extends FieldTypeString> = { [K in keyof M]: M[K] extends Types ? K : never }[keyof M];
|
|
456
|
+
/**
|
|
457
|
+
* Removes keys from M that are sub-fields of a `nested` parent.
|
|
458
|
+
* For example, if `variants` is a nested field, `variants.color` is excluded.
|
|
459
|
+
* Used to prevent root-level query methods from accepting nested descendants —
|
|
460
|
+
* those fields must be queried inside a `.nested()` callback instead.
|
|
461
|
+
*/
|
|
462
|
+
type ExcludeNestedDescendants<M extends Record<string, FieldTypeString>> = { [K in keyof M as K extends `${FieldsOfType<M, 'nested'> & string}.${string}` ? never : K]: M[K] };
|
|
463
|
+
type TextFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'text' | 'match_only_text' | 'search_as_you_type'>;
|
|
464
|
+
type KeywordFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'keyword' | 'constant_keyword' | 'wildcard'>;
|
|
465
|
+
type NumericFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'long' | 'integer' | 'short' | 'byte' | 'double' | 'float' | 'half_float' | 'scaled_float' | 'unsigned_long'>;
|
|
466
|
+
type DateFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'date' | 'date_nanos'>;
|
|
467
|
+
type BooleanFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'boolean'>;
|
|
468
|
+
type GeoPointFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'geo_point'>;
|
|
469
|
+
type GeoShapeFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'geo_shape'>;
|
|
470
|
+
/**
|
|
471
|
+
* Projection covering `rank_feature` and `rank_features` fields — valid targets for
|
|
472
|
+
* the `rank_feature` query and `distance_feature` (when using the rank_feature origin).
|
|
473
|
+
*/
|
|
474
|
+
type RankFeatureFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'rank_feature' | 'rank_features'>;
|
|
475
|
+
/**
|
|
476
|
+
* Umbrella projection covering all vector-shaped field types (dense + sparse).
|
|
477
|
+
* Use the narrower `DenseVectorFields<M>` or `SparseVectorFields<M>` when a
|
|
478
|
+
* specific vector variant is required (e.g. `.knn()` dense-only, `.sparseVector()` sparse-only).
|
|
479
|
+
*/
|
|
480
|
+
type VectorFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'dense_vector' | 'sparse_vector'>;
|
|
481
|
+
/**
|
|
482
|
+
* Fields valid as the target of a `.knn()` query — dense vector fields only.
|
|
483
|
+
* Kept as a dedicated alias so the `.knn()` constraint is explicit and so the broader
|
|
484
|
+
* `VectorFields<M>` umbrella can grow without loosening `.knn()`.
|
|
485
|
+
*/
|
|
486
|
+
type DenseVectorFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'dense_vector'>;
|
|
487
|
+
/**
|
|
488
|
+
* Fields valid as the target of a `.sparseVector()` query — sparse vector fields only.
|
|
489
|
+
* Used by ELSER and other learned-sparse retrieval models.
|
|
490
|
+
*/
|
|
491
|
+
type SparseVectorFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'sparse_vector'>;
|
|
492
|
+
/**
|
|
493
|
+
* Fields valid as the target of a completion suggester.
|
|
494
|
+
*/
|
|
495
|
+
type CompletionFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'completion'>;
|
|
496
|
+
type IpFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'ip'>;
|
|
497
|
+
/**
|
|
498
|
+
* Fields valid for sorting in Elasticsearch.
|
|
499
|
+
* Excludes `object`, `nested`, `dense_vector`, `binary`, `geo_shape`, `geo_point`, and other non-sortable types.
|
|
500
|
+
* Note: `geo_point` fields require the special `_geo_distance` sort syntax, not a plain field sort.
|
|
501
|
+
*/
|
|
502
|
+
type SortableFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'keyword' | 'constant_keyword' | 'long' | 'integer' | 'short' | 'byte' | 'double' | 'float' | 'half_float' | 'scaled_float' | 'date' | 'boolean' | 'ip'>;
|
|
503
|
+
/**
|
|
504
|
+
* Fields valid for field collapsing in Elasticsearch.
|
|
505
|
+
* Collapse requires a keyword or numeric field.
|
|
506
|
+
*/
|
|
507
|
+
type CollapsibleFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'keyword' | 'constant_keyword' | 'long' | 'integer' | 'short' | 'byte' | 'double' | 'float' | 'half_float' | 'scaled_float'>;
|
|
508
|
+
/**
|
|
509
|
+
* Fields valid for highlighting in Elasticsearch.
|
|
510
|
+
* Highlighting applies to text-like and keyword fields only.
|
|
511
|
+
*/
|
|
512
|
+
type HighlightableFields<M extends Record<string, FieldTypeString>> = FieldsOfType<ExcludeNestedDescendants<M>, 'text' | 'match_only_text' | 'search_as_you_type' | 'keyword' | 'constant_keyword' | 'wildcard'>;
|
|
513
|
+
/** Maps a single FieldTypeString to its TypeScript value type. Used by Val<M,K> in query constraints. */
|
|
514
|
+
type FieldValueType<T extends FieldTypeString> = T extends keyof ESTypeToTS ? ESTypeToTS[T] : unknown;
|
|
515
|
+
/**
|
|
516
|
+
* Extracts field names from M that have type `'nested'`.
|
|
517
|
+
* Used to constrain the `path` argument of `.nested()` to valid nested field names.
|
|
518
|
+
*/
|
|
519
|
+
type NestedPathFields<M extends Record<string, FieldTypeString>> = FieldsOfType<M, 'nested'>;
|
|
520
|
+
/**
|
|
521
|
+
* Given a parent field path (e.g. `'tags'`), extracts the sub-fields of that path
|
|
522
|
+
* from the flat expanded M map. Keys like `'tags.label'` become `'label'` in the result.
|
|
523
|
+
*
|
|
524
|
+
* Used to provide a typed `ClauseBuilder` for the inner callback of `.nested()`.
|
|
525
|
+
*/
|
|
526
|
+
type SubFieldsOf<M extends Record<string, FieldTypeString>, Path extends string> = { [K in keyof M as K extends `${Path}.${infer Rest}` ? Rest : never]: M[K] & FieldTypeString };
|
|
527
|
+
//#endregion
|
|
528
|
+
//#region src/index-management.types.d.ts
|
|
529
|
+
/**
|
|
530
|
+
* All supported Elasticsearch field type strings.
|
|
531
|
+
*/
|
|
532
|
+
type FieldTypeString = 'text' | 'match_only_text' | 'keyword' | 'constant_keyword' | 'wildcard' | 'long' | 'integer' | 'short' | 'byte' | 'double' | 'float' | 'half_float' | 'scaled_float' | 'date' | 'date_nanos' | 'boolean' | 'binary' | 'integer_range' | 'float_range' | 'long_range' | 'double_range' | 'date_range' | 'ip_range' | 'ip' | 'alias' | 'object' | 'nested' | 'flattened' | 'geo_point' | 'geo_shape' | 'completion' | 'search_as_you_type' | 'dense_vector' | 'sparse_vector' | 'rank_feature' | 'rank_features' | 'semantic_text' | 'unsigned_long' | 'percolator' | 'token_count' | 'murmur3' | 'join';
|
|
533
|
+
/**
|
|
534
|
+
* Field mapping definition.
|
|
535
|
+
*/
|
|
536
|
+
type FieldMapping = {
|
|
537
|
+
type: FieldTypeString;
|
|
538
|
+
fields?: Record<string, FieldMapping>;
|
|
539
|
+
analyzer?: string;
|
|
540
|
+
search_analyzer?: string;
|
|
541
|
+
boost?: number;
|
|
542
|
+
index?: boolean;
|
|
543
|
+
store?: boolean;
|
|
544
|
+
doc_values?: boolean;
|
|
545
|
+
similarity?: string;
|
|
546
|
+
dims?: number;
|
|
547
|
+
index_options?: any;
|
|
548
|
+
scaling_factor?: number;
|
|
549
|
+
properties?: Record<string, FieldMapping>;
|
|
550
|
+
normalizer?: string;
|
|
551
|
+
format?: string;
|
|
552
|
+
coerce?: boolean;
|
|
553
|
+
enabled?: boolean;
|
|
554
|
+
element_type?: string;
|
|
555
|
+
path?: string;
|
|
556
|
+
max_input_length?: number;
|
|
557
|
+
preserve_separators?: boolean;
|
|
558
|
+
preserve_position_increments?: boolean;
|
|
559
|
+
orientation?: string;
|
|
560
|
+
copy_to?: string | string[];
|
|
561
|
+
index_prefixes?: {
|
|
562
|
+
min_chars?: number;
|
|
563
|
+
max_chars?: number;
|
|
564
|
+
};
|
|
565
|
+
index_phrases?: boolean;
|
|
566
|
+
ignore_malformed?: boolean;
|
|
567
|
+
null_value?: string | number | boolean | {
|
|
568
|
+
lat: number;
|
|
569
|
+
lon: number;
|
|
570
|
+
};
|
|
571
|
+
eager_global_ordinals?: boolean;
|
|
572
|
+
term_vector?: string;
|
|
573
|
+
ignore_above?: number;
|
|
574
|
+
max_shingle_size?: number;
|
|
575
|
+
value?: string;
|
|
576
|
+
depth_limit?: number;
|
|
577
|
+
inference_id?: string;
|
|
578
|
+
search_inference_id?: string;
|
|
579
|
+
};
|
|
580
|
+
/**
|
|
581
|
+
* _source field configuration for index mappings.
|
|
582
|
+
*/
|
|
583
|
+
type SourceConfig = {
|
|
584
|
+
enabled?: boolean;
|
|
585
|
+
includes?: string[];
|
|
586
|
+
excludes?: string[];
|
|
587
|
+
};
|
|
588
|
+
/**
|
|
589
|
+
* Index mappings configuration.
|
|
590
|
+
*/
|
|
591
|
+
type IndexMappings = {
|
|
592
|
+
properties: Record<string, FieldMapping>;
|
|
593
|
+
dynamic?: boolean | 'strict' | 'runtime';
|
|
594
|
+
dynamic_templates?: Partial<Record<string, MappingDynamicTemplate>>[];
|
|
595
|
+
_source?: SourceConfig;
|
|
596
|
+
_meta?: Record<string, unknown>;
|
|
597
|
+
};
|
|
598
|
+
/**
|
|
599
|
+
* Index settings configuration — re-exported from official @elastic/elasticsearch types
|
|
600
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html
|
|
601
|
+
*/
|
|
602
|
+
type IndexSettings = IndicesIndexSettings;
|
|
603
|
+
/**
|
|
604
|
+
* Create index options
|
|
605
|
+
*/
|
|
606
|
+
type CreateIndexOptions = {
|
|
607
|
+
mappings?: IndexMappings;
|
|
608
|
+
settings?: IndexSettings;
|
|
609
|
+
aliases?: Record<string, IndicesAlias>;
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Custom analyzer definition — passthrough to `AnalysisAnalyzer` from `@elastic/elasticsearch`.
|
|
613
|
+
* Covers every built-in analyzer (standard, pattern, keyword, language analyzers, ICU, Kuromoji, etc.).
|
|
614
|
+
*/
|
|
615
|
+
type AnalysisAnalyzerConfig = AnalysisAnalyzer;
|
|
616
|
+
/**
|
|
617
|
+
* Tokenizer passthrough — accepts either a built-in tokenizer name string or a
|
|
618
|
+
* full `AnalysisTokenizerDefinition`.
|
|
619
|
+
*/
|
|
620
|
+
type AnalysisTokenizerConfig = AnalysisTokenizer;
|
|
621
|
+
/**
|
|
622
|
+
* Token filter passthrough — accepts either a built-in token filter name string or a
|
|
623
|
+
* full `AnalysisTokenFilterDefinition`.
|
|
624
|
+
*/
|
|
625
|
+
type AnalysisTokenFilterConfig = AnalysisTokenFilter;
|
|
626
|
+
/**
|
|
627
|
+
* Char filter passthrough — accepts either a built-in char filter name string or a
|
|
628
|
+
* full `AnalysisCharFilterDefinition`.
|
|
629
|
+
*/
|
|
630
|
+
type AnalysisCharFilterConfig = AnalysisCharFilter;
|
|
631
|
+
/**
|
|
632
|
+
* Normalizer passthrough.
|
|
633
|
+
*/
|
|
634
|
+
type AnalysisNormalizerConfig = AnalysisNormalizer;
|
|
635
|
+
/**
|
|
636
|
+
* Analysis settings for an index — configures custom analyzers, tokenizers, token filters, and char filters.
|
|
637
|
+
* Passes through `IndicesIndexSettingsAnalysis` from `@elastic/elasticsearch`, unlocking every
|
|
638
|
+
* built-in and plugin analyzer/tokenizer/filter for free as the Elastic types evolve.
|
|
639
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis.html
|
|
640
|
+
*/
|
|
641
|
+
type AnalysisConfig = IndicesIndexSettingsAnalysis;
|
|
642
|
+
/**
|
|
643
|
+
* Index builder interface.
|
|
644
|
+
*
|
|
645
|
+
* The optional generic `M` carries the field-type map of the attached mapping schema,
|
|
646
|
+
* enabling other builders (or downstream type helpers) to reference the same field
|
|
647
|
+
* constraints that were used to build the index.
|
|
648
|
+
*/
|
|
649
|
+
type IndexBuilder<M extends Record<string, FieldTypeString> = Record<string, FieldTypeString>> = {
|
|
650
|
+
mappings: <NewM extends Record<string, FieldTypeString>>(schemaOrFields: MappingsSchema<NewM> | Record<string, FieldMapping>, options?: MappingOptions) => IndexBuilder<NewM>;
|
|
651
|
+
settings: (settings: IndexSettings) => IndexBuilder<M>; /** Configure custom analyzers, tokenizers, token filters, and char filters for this index. */
|
|
652
|
+
analysis: (config: AnalysisConfig) => IndexBuilder<M>;
|
|
653
|
+
alias: (name: string, options?: IndicesAlias) => IndexBuilder<M>;
|
|
654
|
+
build: () => CreateIndexOptions;
|
|
655
|
+
};
|
|
656
|
+
//#endregion
|
|
657
|
+
//#region src/aggregation.types.d.ts
|
|
658
|
+
/**
|
|
659
|
+
* Options for terms aggregation (excludes 'field' which is handled by the builder)
|
|
660
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
|
|
661
|
+
*/
|
|
662
|
+
type TermsAggOptions = Omit<AggregationsTermsAggregation, 'field'>;
|
|
663
|
+
/**
|
|
664
|
+
* Options for date_histogram aggregation (excludes 'field' which is handled by the builder)
|
|
665
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html
|
|
666
|
+
*/
|
|
667
|
+
type DateHistogramAggOptions = Omit<AggregationsDateHistogramAggregation, 'field'>;
|
|
668
|
+
/**
|
|
669
|
+
* Options for range aggregation (excludes 'field' which is handled by the builder)
|
|
670
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html
|
|
671
|
+
*/
|
|
672
|
+
type RangeAggOptions = Omit<AggregationsRangeAggregation, 'field'>;
|
|
673
|
+
/**
|
|
674
|
+
* Options for histogram aggregation (excludes 'field' which is handled by the builder)
|
|
675
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html
|
|
676
|
+
*/
|
|
677
|
+
type HistogramAggOptions = Omit<AggregationsHistogramAggregation, 'field'>;
|
|
678
|
+
/**
|
|
679
|
+
* Options for avg aggregation (excludes 'field' which is handled by the builder)
|
|
680
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html
|
|
681
|
+
*/
|
|
682
|
+
type AvgAggOptions = Omit<AggregationsAverageAggregation, 'field'>;
|
|
683
|
+
/**
|
|
684
|
+
* Options for sum aggregation (excludes 'field' which is handled by the builder)
|
|
685
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html
|
|
686
|
+
*/
|
|
687
|
+
type SumAggOptions = Omit<AggregationsSumAggregation, 'field'>;
|
|
688
|
+
/**
|
|
689
|
+
* Options for min aggregation (excludes 'field' which is handled by the builder)
|
|
690
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-min-aggregation.html
|
|
691
|
+
*/
|
|
692
|
+
type MinAggOptions = Omit<AggregationsMinAggregation, 'field'>;
|
|
693
|
+
/**
|
|
694
|
+
* Options for max aggregation (excludes 'field' which is handled by the builder)
|
|
695
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html
|
|
696
|
+
*/
|
|
697
|
+
type MaxAggOptions = Omit<AggregationsMaxAggregation, 'field'>;
|
|
698
|
+
/**
|
|
699
|
+
* Options for cardinality aggregation (excludes 'field' which is handled by the builder)
|
|
700
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
|
|
701
|
+
*/
|
|
702
|
+
type CardinalityAggOptions = Omit<AggregationsCardinalityAggregation, 'field'>;
|
|
703
|
+
/**
|
|
704
|
+
* Options for percentiles aggregation (excludes 'field' which is handled by the builder)
|
|
705
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html
|
|
706
|
+
*/
|
|
707
|
+
type PercentilesAggOptions = Omit<AggregationsPercentilesAggregation, 'field'>;
|
|
708
|
+
/**
|
|
709
|
+
* Options for stats aggregation (excludes 'field' which is handled by the builder)
|
|
710
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html
|
|
711
|
+
*/
|
|
712
|
+
type StatsAggOptions = Omit<AggregationsStatsAggregation, 'field'>;
|
|
713
|
+
/**
|
|
714
|
+
* Options for value_count aggregation (excludes 'field' which is handled by the builder)
|
|
715
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html
|
|
716
|
+
*/
|
|
717
|
+
type ValueCountAggOptions = Omit<AggregationsValueCountAggregation, 'field'>;
|
|
718
|
+
/**
|
|
719
|
+
* Options for extended_stats aggregation (excludes 'field' which is handled by the builder)
|
|
720
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-extendedstats-aggregation.html
|
|
721
|
+
*/
|
|
722
|
+
type ExtendedStatsAggOptions = Omit<AggregationsExtendedStatsAggregation, 'field'>;
|
|
723
|
+
/**
|
|
724
|
+
* Options for top_hits aggregation
|
|
725
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html
|
|
726
|
+
*/
|
|
727
|
+
type TopHitsAggOptions = AggregationsTopHitsAggregation;
|
|
728
|
+
/**
|
|
729
|
+
* Options for auto_date_histogram aggregation (excludes 'field' which is handled by the builder)
|
|
730
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-autodatehistogram-aggregation.html
|
|
731
|
+
*/
|
|
732
|
+
type AutoDateHistogramAggOptions = Omit<AggregationsAutoDateHistogramAggregation, 'field'>;
|
|
733
|
+
/**
|
|
734
|
+
* Options for date_range aggregation (excludes 'field' which is handled by the builder).
|
|
735
|
+
* Complement to `range` for date-typed fields; supports date-math expressions in `ranges[].from`/`to`.
|
|
736
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html
|
|
737
|
+
*/
|
|
738
|
+
type DateRangeAggOptions = Omit<AggregationsDateRangeAggregation, 'field'>;
|
|
739
|
+
/**
|
|
740
|
+
* Options for filters aggregation — multi-filter buckets. Distinct from the single-query
|
|
741
|
+
* `.filter(name, query)` metric-wrapping aggregation. `filters` creates one named bucket per
|
|
742
|
+
* supplied query, plus an optional `other_bucket` for non-matches.
|
|
743
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html
|
|
744
|
+
*/
|
|
745
|
+
type FiltersAggOptions = Omit<AggregationsFiltersAggregation, 'filters'>;
|
|
746
|
+
/**
|
|
747
|
+
* Options for significant_terms aggregation (excludes 'field' which is handled by the builder).
|
|
748
|
+
* Text-analytics staple — returns terms that are statistically significant in the foreground
|
|
749
|
+
* set relative to the background set.
|
|
750
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html
|
|
751
|
+
*/
|
|
752
|
+
type SignificantTermsAggOptions = Omit<AggregationsSignificantTermsAggregation, 'field'>;
|
|
753
|
+
/** Options for rare_terms aggregation (excludes 'field' which is handled by the builder) */
|
|
754
|
+
type RareTermsAggOptions = Omit<AggregationsRareTermsAggregation, 'field'>;
|
|
755
|
+
/** Options for multi_terms aggregation — full passthrough (field is inside `terms` array) */
|
|
756
|
+
type MultiTermsAggOptions = AggregationsMultiTermsAggregation;
|
|
757
|
+
/** Options for geo_distance aggregation (excludes 'field' which is handled by the builder) */
|
|
758
|
+
type GeoDistanceAggOptions = Omit<AggregationsGeoDistanceAggregation, 'field'>;
|
|
759
|
+
/** Options for geohash_grid aggregation (excludes 'field' which is handled by the builder) */
|
|
760
|
+
type GeohashGridAggOptions = Omit<AggregationsGeoHashGridAggregation, 'field'>;
|
|
761
|
+
/** Options for geotile_grid aggregation (excludes 'field' which is handled by the builder) */
|
|
762
|
+
type GeotileGridAggOptions = Omit<AggregationsGeoTileGridAggregation, 'field'>;
|
|
763
|
+
/** Options for geo_bounds aggregation (excludes 'field' which is handled by the builder) */
|
|
764
|
+
type GeoBoundsAggOptions = Omit<AggregationsGeoBoundsAggregation, 'field'>;
|
|
765
|
+
/** Options for geo_centroid aggregation (excludes 'field' which is handled by the builder) */
|
|
766
|
+
type GeoCentroidAggOptions = Omit<AggregationsGeoCentroidAggregation, 'field'>;
|
|
767
|
+
/** Options for missing aggregation (excludes 'field' which is handled by the builder) */
|
|
768
|
+
type MissingAggOptions = Omit<AggregationsMissingAggregation, 'field'>;
|
|
769
|
+
/** Options for top_metrics aggregation — full passthrough (metrics and sort in options) */
|
|
770
|
+
type TopMetricsAggOptions = AggregationsTopMetricsAggregation;
|
|
771
|
+
/** Options for weighted_avg aggregation — full passthrough (value and weight in options) */
|
|
772
|
+
type WeightedAvgAggOptions = AggregationsWeightedAverageAggregation;
|
|
773
|
+
/** Options for bucket_script pipeline aggregation — full passthrough */
|
|
774
|
+
type BucketScriptAggOptions = AggregationsBucketScriptAggregation;
|
|
775
|
+
/** Options for bucket_selector pipeline aggregation — full passthrough */
|
|
776
|
+
type BucketSelectorAggOptions = AggregationsBucketSelectorAggregation;
|
|
777
|
+
/** Options for derivative pipeline aggregation — full passthrough */
|
|
778
|
+
type DerivativeAggOptions = AggregationsDerivativeAggregation;
|
|
779
|
+
/** Options for cumulative_sum pipeline aggregation — full passthrough */
|
|
780
|
+
type CumulativeSumAggOptions = AggregationsCumulativeSumAggregation;
|
|
781
|
+
/**
|
|
782
|
+
* Source entry for composite aggregation — a named single-value source definition
|
|
783
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html
|
|
784
|
+
*/
|
|
785
|
+
type CompositeAggSource = Record<string, AggregationsCompositeAggregationSource>;
|
|
786
|
+
/**
|
|
787
|
+
* Options for composite aggregation (excludes 'sources' which is handled by the builder)
|
|
788
|
+
*/
|
|
789
|
+
type CompositeAggOptions = Omit<AggregationsCompositeAggregation, 'sources'>;
|
|
790
|
+
/**
|
|
791
|
+
* Aggregation state for build output
|
|
792
|
+
*/
|
|
793
|
+
type AggregationState = {
|
|
794
|
+
[key: string]: any;
|
|
795
|
+
};
|
|
796
|
+
/**
|
|
797
|
+
* Shared metric and bucket aggregation methods.
|
|
798
|
+
* `Self` is the return type for each method — varies by context (root vs nested).
|
|
799
|
+
*/
|
|
800
|
+
type BaseAggMethods<M extends Record<string, FieldTypeString>, Self> = {
|
|
801
|
+
terms: <K extends (KeywordFields<M> | NumericFields<M> | BooleanFields<M> | IpFields<M>) & string>(name: string, field: K, options?: TermsAggOptions) => Self;
|
|
802
|
+
dateHistogram: <K extends DateFields<M> & string>(name: string, field: K, options?: DateHistogramAggOptions) => Self;
|
|
803
|
+
range: <K extends (NumericFields<M> | DateFields<M>) & string>(name: string, field: K, options?: RangeAggOptions) => Self; /** Date-range aggregation — complement to `range` for date-typed fields. Supports date-math in range bounds. */
|
|
804
|
+
dateRange: <K extends DateFields<M> & string>(name: string, field: K, options?: DateRangeAggOptions) => Self;
|
|
805
|
+
/**
|
|
806
|
+
* Multi-filter aggregation — creates one named bucket per supplied query, plus an optional
|
|
807
|
+
* `other_bucket` for non-matches. Distinct from the single-query `.filter(name, query)`.
|
|
808
|
+
*/
|
|
809
|
+
filters: (name: string, filters: Record<string, QueryDslQueryContainer>, options?: FiltersAggOptions) => Self; /** Significant-terms aggregation — statistically significant terms relative to the background set. */
|
|
810
|
+
significantTerms: <K extends (KeywordFields<M> | TextFields<M>) & string>(name: string, field: K, options?: SignificantTermsAggOptions) => Self;
|
|
811
|
+
histogram: <K extends NumericFields<M> & string>(name: string, field: K, options?: HistogramAggOptions) => Self;
|
|
812
|
+
avg: <K extends NumericFields<M> & string>(name: string, field: K, options?: AvgAggOptions) => Self;
|
|
813
|
+
sum: <K extends NumericFields<M> & string>(name: string, field: K, options?: SumAggOptions) => Self;
|
|
814
|
+
min: <K extends NumericFields<M> & string>(name: string, field: K, options?: MinAggOptions) => Self;
|
|
815
|
+
max: <K extends NumericFields<M> & string>(name: string, field: K, options?: MaxAggOptions) => Self;
|
|
816
|
+
cardinality: <K extends (KeywordFields<M> | TextFields<M> | NumericFields<M> | DateFields<M> | BooleanFields<M> | IpFields<M>) & string>(name: string, field: K, options?: CardinalityAggOptions) => Self;
|
|
817
|
+
percentiles: <K extends NumericFields<M> & string>(name: string, field: K, options?: PercentilesAggOptions) => Self;
|
|
818
|
+
stats: <K extends NumericFields<M> & string>(name: string, field: K, options?: StatsAggOptions) => Self;
|
|
819
|
+
valueCount: <K extends (KeywordFields<M> | TextFields<M> | NumericFields<M> | DateFields<M> | BooleanFields<M> | IpFields<M>) & string>(name: string, field: K, options?: ValueCountAggOptions) => Self;
|
|
820
|
+
extendedStats: <K extends NumericFields<M> & string>(name: string, field: K, options?: ExtendedStatsAggOptions) => Self;
|
|
821
|
+
topHits: (name: string, options?: TopHitsAggOptions) => Self;
|
|
822
|
+
autoDateHistogram: <K extends DateFields<M> & string>(name: string, field: K, options?: AutoDateHistogramAggOptions) => Self;
|
|
823
|
+
composite: (name: string, sources: CompositeAggSource[], options?: CompositeAggOptions) => Self;
|
|
824
|
+
filter: (name: string, query: QueryDslQueryContainer) => Self; /** Rare-terms aggregation — returns terms that are rare in the index (inverse of terms). */
|
|
825
|
+
rareTerms: <K extends (KeywordFields<M> | NumericFields<M> | IpFields<M>) & string>(name: string, field: K, options?: RareTermsAggOptions) => Self; /** Multi-terms aggregation — creates buckets from combinations of multiple field values. */
|
|
826
|
+
multiTerms: (name: string, options: MultiTermsAggOptions) => Self; /** Geo-distance aggregation — buckets documents by distance from an origin point. */
|
|
827
|
+
geoDistance: <K extends GeoPointFields<M> & string>(name: string, field: K, options: GeoDistanceAggOptions) => Self; /** Geohash-grid aggregation — groups geo_point values into grid cells. */
|
|
828
|
+
geohashGrid: <K extends GeoPointFields<M> & string>(name: string, field: K, options?: GeohashGridAggOptions) => Self; /** Geotile-grid aggregation — groups geo_point values into map tile cells. */
|
|
829
|
+
geotileGrid: <K extends GeoPointFields<M> & string>(name: string, field: K, options?: GeotileGridAggOptions) => Self; /** Geo-bounds aggregation — computes the bounding box containing all geo_point values. */
|
|
830
|
+
geoBounds: <K extends GeoPointFields<M> & string>(name: string, field: K, options?: GeoBoundsAggOptions) => Self; /** Geo-centroid aggregation — computes the weighted centroid of all geo_point values. */
|
|
831
|
+
geoCentroid: <K extends GeoPointFields<M> & string>(name: string, field: K, options?: GeoCentroidAggOptions) => Self; /** Missing aggregation — counts documents with missing or null values for a field. */
|
|
832
|
+
missing: <K extends (KeywordFields<M> | TextFields<M> | NumericFields<M> | DateFields<M> | BooleanFields<M> | IpFields<M>) & string>(name: string, field: K, options?: MissingAggOptions) => Self; /** Top-metrics aggregation — returns the top document's metrics sorted by a given criterion. */
|
|
833
|
+
topMetrics: (name: string, options: TopMetricsAggOptions) => Self; /** Weighted-average aggregation — computes a weighted average of numeric values. */
|
|
834
|
+
weightedAvg: (name: string, options: WeightedAvgAggOptions) => Self; /** Bucket-script pipeline aggregation — executes a script on bucket values from other aggs. */
|
|
835
|
+
bucketScript: (name: string, options: BucketScriptAggOptions) => Self; /** Bucket-selector pipeline aggregation — filters buckets based on a script predicate. */
|
|
836
|
+
bucketSelector: (name: string, options: BucketSelectorAggOptions) => Self; /** Derivative pipeline aggregation — calculates the derivative of a metric in a parent histogram/date_histogram. */
|
|
837
|
+
derivative: (name: string, options: DerivativeAggOptions) => Self; /** Cumulative-sum pipeline aggregation — calculates the cumulative sum of a metric in a parent histogram/date_histogram. */
|
|
838
|
+
cumulativeSum: (name: string, options: CumulativeSumAggOptions) => Self;
|
|
839
|
+
build: () => AggregationState;
|
|
840
|
+
};
|
|
841
|
+
/**
|
|
842
|
+
* Root-level aggregation builder. Supports `global` and `nested`; does not expose `reverseNested`.
|
|
843
|
+
*
|
|
844
|
+
* Declared as an `interface` (not a `type` alias) so that TypeScript's lazy interface resolution
|
|
845
|
+
* handles the 3-way mutual recursion between `RootAggregationBuilder`, `NestedEntryBuilder`,
|
|
846
|
+
* and `NestedAggregationBuilder` without triggering TS2456 (circular type alias).
|
|
847
|
+
*/
|
|
848
|
+
interface RootAggregationBuilder<M extends Record<string, FieldTypeString>> extends BaseAggMethods<M, RootAggregationBuilder<M>> {
|
|
849
|
+
/** Global aggregation — escapes the current filter context to aggregate across all documents.
|
|
850
|
+
* @remarks Only valid at the root aggregation level, not inside a nested context. */
|
|
851
|
+
global: (name: string) => RootAggregationBuilder<M>;
|
|
852
|
+
/** Nested aggregation — enters a nested document context for aggregating nested fields.
|
|
853
|
+
* Returns a `NestedEntryBuilder` whose `subAgg` callback receives the nested sub-field types. */
|
|
854
|
+
nested: <K extends NestedPathFields<M> & string>(name: string, path: K) => NestedEntryBuilder<M, SubFieldsOf<M, K>, RootAggregationBuilder<M>, M>;
|
|
855
|
+
/** Add sub-aggregation to the last bucket aggregation */
|
|
856
|
+
subAgg: (fn: (agg: RootAggregationBuilder<M>) => RootAggregationBuilder<M>) => RootAggregationBuilder<M>;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Returned by `.nested()` on a root or nested builder.
|
|
860
|
+
*
|
|
861
|
+
* Dual-context design: metric/bucket helpers inherited from `BaseAggMethods<M, R>` operate
|
|
862
|
+
* on the parent field map `M` (sibling aggregations), while the `subAgg` callback is typed
|
|
863
|
+
* to `NestedAggregationBuilder<N>`, giving it access only to the nested sub-fields `N`.
|
|
864
|
+
*
|
|
865
|
+
* `R` is the parent context — `RootAggregationBuilder<M>` when called from root,
|
|
866
|
+
* `NestedAggregationBuilder<M>` when called from inside a nested context.
|
|
867
|
+
*/
|
|
868
|
+
interface NestedEntryBuilder<M extends Record<string, FieldTypeString>, N extends Record<string, FieldTypeString>, R = RootAggregationBuilder<M>, Root extends Record<string, FieldTypeString> = M> extends BaseAggMethods<M, R> {
|
|
869
|
+
global: (name: string) => RootAggregationBuilder<M>;
|
|
870
|
+
nested: <K extends NestedPathFields<M> & string>(name: string, path: K) => NestedEntryBuilder<M, SubFieldsOf<M, K>, R, Root>;
|
|
871
|
+
subAgg: (fn: (agg: NestedAggregationBuilder<N, Root>) => NestedAggregationBuilder<N, Root>) => R;
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Nested-context aggregation builder. Supports `reverseNested` and nested-level `nested`;
|
|
875
|
+
* does not expose `global`.
|
|
876
|
+
*/
|
|
877
|
+
interface NestedAggregationBuilder<N extends Record<string, FieldTypeString>, Root extends Record<string, FieldTypeString> = N> extends BaseAggMethods<N, NestedAggregationBuilder<N, Root>> {
|
|
878
|
+
/** Nested aggregation within a nested context — supports multi-level nesting */
|
|
879
|
+
nested: <K extends NestedPathFields<N> & string>(name: string, path: K) => NestedEntryBuilder<N, SubFieldsOf<N, K>, NestedAggregationBuilder<N, Root>, Root>;
|
|
880
|
+
/** Reverse nested aggregation — returns from a nested context back to the root document.
|
|
881
|
+
* @remarks Only valid inside a nested aggregation context. */
|
|
882
|
+
reverseNested: (name: string, path?: string) => NestedAggregationBuilder<Root, Root>;
|
|
883
|
+
/** Add sub-aggregation to the last bucket aggregation */
|
|
884
|
+
subAgg: (fn: (agg: NestedAggregationBuilder<N, Root>) => NestedAggregationBuilder<N, Root>) => NestedAggregationBuilder<N, Root>;
|
|
885
|
+
}
|
|
886
|
+
//#endregion
|
|
887
|
+
//#region src/vector.types.d.ts
|
|
888
|
+
/**
|
|
889
|
+
* Options for KNN (k-nearest neighbors) query (excludes 'field' and 'query_vector' which are handled by the builder)
|
|
890
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/knn-search.html
|
|
891
|
+
*/
|
|
892
|
+
type KnnOptions = Omit<KnnSearch, 'field' | 'query_vector'>;
|
|
893
|
+
//#endregion
|
|
894
|
+
//#region src/suggester.types.d.ts
|
|
895
|
+
/**
|
|
896
|
+
* Phrase suggester direct-generator config — re-exported from official @elastic/elasticsearch types.
|
|
897
|
+
* Used in `PhraseSuggesterOptions.direct_generator`.
|
|
898
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html#phrase-suggester
|
|
899
|
+
*/
|
|
900
|
+
type PhraseSuggestDirectGenerator = SearchDirectGenerator;
|
|
901
|
+
/**
|
|
902
|
+
* Phrase suggester collate config — re-exported from official @elastic/elasticsearch types.
|
|
903
|
+
* Used in `PhraseSuggesterOptions.collate` to run a query against each candidate phrase.
|
|
904
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html#_collate
|
|
905
|
+
*/
|
|
906
|
+
type PhraseSuggestCollate = SearchPhraseSuggestCollate;
|
|
907
|
+
/**
|
|
908
|
+
* Phrase suggester smoothing-model container — re-exported from official @elastic/elasticsearch types.
|
|
909
|
+
* Used in `PhraseSuggesterOptions.smoothing`.
|
|
910
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html#_smoothing_models
|
|
911
|
+
*/
|
|
912
|
+
type PhraseSuggestSmoothingModel = SearchSmoothingModelContainer;
|
|
913
|
+
/**
|
|
914
|
+
* Completion suggester context — re-exported from official @elastic/elasticsearch types.
|
|
915
|
+
* Used in `CompletionSuggesterOptions.contexts`.
|
|
916
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/suggester-context.html
|
|
917
|
+
*/
|
|
918
|
+
type CompletionSuggestContext = SearchCompletionContext;
|
|
919
|
+
/**
|
|
920
|
+
* Options for term suggester — mirrors the official `SearchTermSuggester` type.
|
|
921
|
+
* `field`, `text`, and `prefix` are omitted because they are supplied by the builder
|
|
922
|
+
* as explicit arguments (`field` is re-added below, narrowed to the mapping schema).
|
|
923
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html#term-suggester
|
|
924
|
+
*/
|
|
925
|
+
type TermSuggesterOptions<M extends Record<string, FieldTypeString>> = Omit<SearchTermSuggester, 'field' | 'text' | 'prefix'> & {
|
|
926
|
+
field: (TextFields<M> | KeywordFields<M>) & string;
|
|
927
|
+
};
|
|
928
|
+
/**
|
|
929
|
+
* Options for phrase suggester — mirrors the official `SearchPhraseSuggester` type
|
|
930
|
+
* with `field`, `text`, and `prefix` removed (builder-owned).
|
|
931
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html#phrase-suggester
|
|
932
|
+
*/
|
|
933
|
+
type PhraseSuggesterOptions<M extends Record<string, FieldTypeString>> = Omit<SearchPhraseSuggester, 'field' | 'text' | 'prefix'> & {
|
|
934
|
+
field: (TextFields<M> | KeywordFields<M>) & string;
|
|
935
|
+
};
|
|
936
|
+
/**
|
|
937
|
+
* Options for completion suggester — mirrors the official `SearchCompletionSuggester` type
|
|
938
|
+
* with `field`, `text`, and `prefix` removed (builder-owned).
|
|
939
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html#completion-suggester
|
|
940
|
+
*/
|
|
941
|
+
type CompletionSuggesterOptions<M extends Record<string, FieldTypeString>> = Omit<SearchCompletionSuggester, 'field' | 'text' | 'prefix'> & {
|
|
942
|
+
field: CompletionFields<M> & string;
|
|
943
|
+
};
|
|
944
|
+
/**
|
|
945
|
+
* Suggester state for build output.
|
|
946
|
+
*
|
|
947
|
+
* The state carries the suggester DSL as Elasticsearch accepts it — options still
|
|
948
|
+
* embed `field` internally after the builder writes them, since that is how the
|
|
949
|
+
* underlying wire format works. The type-safety benefit lives at the method
|
|
950
|
+
* boundary: callers cannot pass a non-existent field to `.term()`/`.phrase()`/`.completion()`.
|
|
951
|
+
*/
|
|
952
|
+
type SuggesterState = {
|
|
953
|
+
[suggesterName: string]: {
|
|
954
|
+
text?: string;
|
|
955
|
+
prefix?: string;
|
|
956
|
+
term?: Omit<SearchTermSuggester, 'text' | 'prefix'>;
|
|
957
|
+
phrase?: Omit<SearchPhraseSuggester, 'text' | 'prefix'>;
|
|
958
|
+
completion?: Omit<SearchCompletionSuggester, 'text' | 'prefix'>;
|
|
959
|
+
};
|
|
960
|
+
};
|
|
961
|
+
/**
|
|
962
|
+
* Suggester builder interface
|
|
963
|
+
*/
|
|
964
|
+
type SuggesterBuilder<M extends Record<string, FieldTypeString>> = {
|
|
965
|
+
/** Term suggester - suggests corrections for individual terms */term: (name: string, text: string, options: TermSuggesterOptions<M>) => SuggesterBuilder<M>; /** Phrase suggester - suggests corrections for entire phrases */
|
|
966
|
+
phrase: (name: string, text: string, options: PhraseSuggesterOptions<M>) => SuggesterBuilder<M>; /** Completion suggester - autocomplete functionality */
|
|
967
|
+
completion: (name: string, prefix: string, options: CompletionSuggesterOptions<M>) => SuggesterBuilder<M>; /** Build suggester DSL */
|
|
968
|
+
build: () => {
|
|
969
|
+
suggest: SuggesterState;
|
|
970
|
+
};
|
|
971
|
+
};
|
|
972
|
+
//#endregion
|
|
973
|
+
//#region src/query.types.d.ts
|
|
974
|
+
type MatchOptions = Omit<QueryDslMatchQuery, 'query'>;
|
|
975
|
+
type MultiMatchOptions = Omit<QueryDslMultiMatchQuery, 'query' | 'fields'>;
|
|
976
|
+
type FuzzyOptions = Omit<QueryDslFuzzyQuery, 'value'>;
|
|
977
|
+
type HighlightOptions = SearchHighlightBase;
|
|
978
|
+
type RegexpOptions = Omit<QueryDslRegexpQuery, 'value'>;
|
|
979
|
+
type ConstantScoreOptions = Omit<QueryDslConstantScoreQuery, 'filter'>;
|
|
980
|
+
type MatchPhrasePrefixOptions = Omit<QueryDslMatchPhrasePrefixQuery, 'query'>;
|
|
981
|
+
type GeoDistanceOptions = {
|
|
982
|
+
distance: string | number;
|
|
983
|
+
unit?: 'mi' | 'km' | 'mm' | 'cm' | 'm' | 'yd' | 'ft' | 'in' | 'nmi';
|
|
984
|
+
distance_type?: 'arc' | 'plane';
|
|
985
|
+
};
|
|
986
|
+
type GeoBoundingBoxOptions = {
|
|
987
|
+
top_left?: {
|
|
988
|
+
lat: number;
|
|
989
|
+
lon: number;
|
|
990
|
+
};
|
|
991
|
+
bottom_right?: {
|
|
992
|
+
lat: number;
|
|
993
|
+
lon: number;
|
|
994
|
+
};
|
|
995
|
+
top?: number;
|
|
996
|
+
left?: number;
|
|
997
|
+
bottom?: number;
|
|
998
|
+
right?: number;
|
|
999
|
+
};
|
|
1000
|
+
type GeoPolygonOptions = {
|
|
1001
|
+
points: Array<{
|
|
1002
|
+
lat: number;
|
|
1003
|
+
lon: number;
|
|
1004
|
+
}>;
|
|
1005
|
+
};
|
|
1006
|
+
type GeoShapeQueryOptions = {
|
|
1007
|
+
relation?: 'intersects' | 'disjoint' | 'within' | 'contains';
|
|
1008
|
+
boost?: number;
|
|
1009
|
+
ignore_unmapped?: boolean;
|
|
1010
|
+
};
|
|
1011
|
+
type ScriptOptions = Script;
|
|
1012
|
+
type ScriptQueryOptions = Script & Omit<QueryDslScriptQuery, 'script'>;
|
|
1013
|
+
type ScriptScoreOptions = Omit<QueryDslScriptScoreQuery, 'query' | 'script'>;
|
|
1014
|
+
type PercolateOptions = QueryDslPercolateQuery;
|
|
1015
|
+
type CombinedFieldsOptions = Omit<QueryDslCombinedFieldsQuery, 'query' | 'fields'>;
|
|
1016
|
+
type QueryStringOptions = Omit<QueryDslQueryStringQuery, 'query'>;
|
|
1017
|
+
type SimpleQueryStringOptions = Omit<QueryDslSimpleQueryStringQuery, 'query'>;
|
|
1018
|
+
type MoreLikeThisOptions = Omit<QueryDslMoreLikeThisQuery, 'fields' | 'like'>;
|
|
1019
|
+
type MatchBoolPrefixOptions = Omit<QueryDslMatchBoolPrefixQuery, 'query'>;
|
|
1020
|
+
type NestedOptions = Omit<QueryDslNestedQuery, 'path' | 'query'>;
|
|
1021
|
+
type FunctionScoreOptions = Omit<QueryDslFunctionScoreQuery, 'query'>;
|
|
1022
|
+
type HasChildOptions = Omit<QueryDslHasChildQuery, 'query' | 'type'>;
|
|
1023
|
+
type HasParentOptions = Omit<QueryDslHasParentQuery, 'query' | 'parent_type'>;
|
|
1024
|
+
type ParentIdOptions = Omit<QueryDslParentIdQuery, 'id' | 'type'>;
|
|
1025
|
+
/**
|
|
1026
|
+
* Options for the `intervals` query — the field is supplied as the first argument.
|
|
1027
|
+
* The value is the full `QueryDslIntervalsQuery` rule (match, prefix, wildcard, fuzzy, all_of, any_of, etc.).
|
|
1028
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-intervals-query.html
|
|
1029
|
+
*/
|
|
1030
|
+
type IntervalsOptions = QueryDslIntervalsQuery;
|
|
1031
|
+
/**
|
|
1032
|
+
* Options for `spanNear` — `clauses` is supplied as the first argument.
|
|
1033
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html
|
|
1034
|
+
*/
|
|
1035
|
+
type SpanNearOptions = Omit<QueryDslSpanNearQuery, 'clauses'>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Options for `spanNot` — `include` and `exclude` are supplied as the first two arguments.
|
|
1038
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-not-query.html
|
|
1039
|
+
*/
|
|
1040
|
+
type SpanNotOptions = Omit<QueryDslSpanNotQuery, 'include' | 'exclude'>;
|
|
1041
|
+
/** Re-export the Elastic span query container for composing span clauses. */
|
|
1042
|
+
type SpanQuery = QueryDslSpanQuery;
|
|
1043
|
+
/**
|
|
1044
|
+
* Options for the `distance_feature` query — boosts documents by proximity of a
|
|
1045
|
+
* `date`, `date_nanos`, or `geo_point` field to a given origin. The builder
|
|
1046
|
+
* supplies `field` as an explicit argument and constrains it to date/geo fields.
|
|
1047
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-distance-feature-query.html
|
|
1048
|
+
*/
|
|
1049
|
+
type DistanceFeatureOptions = Omit<QueryDslDistanceFeatureQuery, 'field'>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Options for the `rank_feature` query — boosts relevance using a numeric feature
|
|
1052
|
+
* stored in a `rank_feature` or `rank_features` field. The builder supplies
|
|
1053
|
+
* `field` as an explicit argument.
|
|
1054
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-rank-feature-query.html
|
|
1055
|
+
*/
|
|
1056
|
+
type RankFeatureQueryOptions = Omit<QueryDslRankFeatureQuery, 'field'>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Options for the `sparse_vector` query — scores documents using token-weight
|
|
1059
|
+
* vectors produced by a learned sparse model (e.g. ELSER). The builder supplies
|
|
1060
|
+
* `field` as an explicit argument.
|
|
1061
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-sparse-vector-query.html
|
|
1062
|
+
*/
|
|
1063
|
+
type SparseVectorQueryOptions = Omit<QueryDslSparseVectorQuery, 'field'>;
|
|
1064
|
+
type TermableFields<M extends Record<string, FieldTypeString>> = KeywordFields<M> | NumericFields<M> | DateFields<M> | BooleanFields<M> | IpFields<M>;
|
|
1065
|
+
type RangeableFields<M extends Record<string, FieldTypeString>> = NumericFields<M> | DateFields<M> | KeywordFields<M> | IpFields<M>;
|
|
1066
|
+
type FuzzyableFields<M extends Record<string, FieldTypeString>> = TextFields<M> | KeywordFields<M>;
|
|
1067
|
+
type Val<M extends Record<string, FieldTypeString>, K extends keyof M> = FieldValueType<M[K]>;
|
|
1068
|
+
type QueryState<M extends Record<string, FieldTypeString>> = {
|
|
1069
|
+
_includeQuery?: boolean;
|
|
1070
|
+
query?: QueryDslQueryContainer;
|
|
1071
|
+
knn?: {
|
|
1072
|
+
field: string;
|
|
1073
|
+
query_vector?: number[];
|
|
1074
|
+
query_vector_builder?: QueryVectorBuilder;
|
|
1075
|
+
k?: number;
|
|
1076
|
+
num_candidates?: number;
|
|
1077
|
+
filter?: QueryDslQueryContainer | QueryDslQueryContainer[];
|
|
1078
|
+
boost?: number;
|
|
1079
|
+
similarity?: number;
|
|
1080
|
+
inner_hits?: SearchInnerHits;
|
|
1081
|
+
rescore_vector?: RescoreVector;
|
|
1082
|
+
visit_percentage?: number;
|
|
1083
|
+
};
|
|
1084
|
+
aggs?: AggregationState;
|
|
1085
|
+
suggest?: SuggesterState;
|
|
1086
|
+
from?: number;
|
|
1087
|
+
size?: number;
|
|
1088
|
+
sort?: Array<Record<string, 'asc' | 'desc'>>;
|
|
1089
|
+
_source?: Array<string & keyof M>;
|
|
1090
|
+
timeout?: string;
|
|
1091
|
+
track_scores?: boolean;
|
|
1092
|
+
explain?: boolean;
|
|
1093
|
+
min_score?: number;
|
|
1094
|
+
version?: boolean;
|
|
1095
|
+
seq_no_primary_term?: boolean;
|
|
1096
|
+
track_total_hits?: boolean | number;
|
|
1097
|
+
highlight?: {
|
|
1098
|
+
fields: Record<string, HighlightOptions>;
|
|
1099
|
+
pre_tags?: string[];
|
|
1100
|
+
post_tags?: string[];
|
|
1101
|
+
};
|
|
1102
|
+
search_after?: SortResults;
|
|
1103
|
+
preference?: string;
|
|
1104
|
+
collapse?: {
|
|
1105
|
+
field: string;
|
|
1106
|
+
inner_hits?: SearchInnerHits;
|
|
1107
|
+
max_concurrent_group_searches?: number;
|
|
1108
|
+
};
|
|
1109
|
+
rescore?: {
|
|
1110
|
+
window_size: number;
|
|
1111
|
+
query: {
|
|
1112
|
+
rescore_query: QueryDslQueryContainer;
|
|
1113
|
+
query_weight?: number;
|
|
1114
|
+
rescore_query_weight?: number;
|
|
1115
|
+
score_mode?: 'total' | 'multiply' | 'avg' | 'max' | 'min';
|
|
1116
|
+
};
|
|
1117
|
+
};
|
|
1118
|
+
stored_fields?: Array<string>;
|
|
1119
|
+
terminate_after?: number;
|
|
1120
|
+
pit?: {
|
|
1121
|
+
id: string;
|
|
1122
|
+
keep_alive: string;
|
|
1123
|
+
};
|
|
1124
|
+
indices_boost?: Array<Record<string, number>>;
|
|
1125
|
+
runtime_mappings?: Record<string, MappingRuntimeField>;
|
|
1126
|
+
docvalue_fields?: Array<QueryDslFieldAndFormat | string>;
|
|
1127
|
+
fields?: Array<QueryDslFieldAndFormat | string>;
|
|
1128
|
+
post_filter?: QueryDslQueryContainer;
|
|
1129
|
+
script_fields?: Record<string, ScriptField>;
|
|
1130
|
+
_source_includes?: string[];
|
|
1131
|
+
_source_excludes?: string[];
|
|
1132
|
+
};
|
|
1133
|
+
type ClauseBuilder<M extends Record<string, FieldTypeString>> = {
|
|
1134
|
+
matchAll: () => any;
|
|
1135
|
+
matchNone: () => any;
|
|
1136
|
+
match: <K extends TextFields<M> & string>(field: K, value: string, options?: MatchOptions) => any;
|
|
1137
|
+
multiMatch: <K extends TextFields<M> & string>(fields: K[], value: string, options?: MultiMatchOptions) => any;
|
|
1138
|
+
matchPhrase: <K extends TextFields<M> & string>(field: K, value: string) => any;
|
|
1139
|
+
matchPhrasePrefix: <K extends TextFields<M> & string>(field: K, value: string, options?: MatchPhrasePrefixOptions) => any;
|
|
1140
|
+
term: <K extends TermableFields<M> & string>(field: K, value: Val<M, K>) => any;
|
|
1141
|
+
terms: <K extends TermableFields<M> & string>(field: K, value: Array<Val<M, K>>) => any;
|
|
1142
|
+
range: <K extends RangeableFields<M> & string>(field: K, conditions: {
|
|
1143
|
+
gte?: Val<M, K>;
|
|
1144
|
+
lte?: Val<M, K>;
|
|
1145
|
+
gt?: Val<M, K>;
|
|
1146
|
+
lt?: Val<M, K>;
|
|
1147
|
+
}) => any;
|
|
1148
|
+
exists: <K extends string & keyof M>(field: K) => any;
|
|
1149
|
+
prefix: <K extends KeywordFields<M> & string>(field: K, value: string) => any;
|
|
1150
|
+
wildcard: <K extends KeywordFields<M> & string>(field: K, value: string) => any;
|
|
1151
|
+
fuzzy: <K extends FuzzyableFields<M> & string>(field: K, value: string, options?: FuzzyOptions) => any;
|
|
1152
|
+
ids: (values: string[]) => any;
|
|
1153
|
+
knn: <K extends DenseVectorFields<M> & string>(field: K, queryVector: number[], options: KnnOptions) => any;
|
|
1154
|
+
regexp: <K extends KeywordFields<M> & string>(field: K, value: string, options?: RegexpOptions) => any;
|
|
1155
|
+
geoDistance: <K extends GeoPointFields<M> & string>(field: K, center: {
|
|
1156
|
+
lat: number;
|
|
1157
|
+
lon: number;
|
|
1158
|
+
}, options: GeoDistanceOptions) => any;
|
|
1159
|
+
geoBoundingBox: <K extends GeoPointFields<M> & string>(field: K, options: GeoBoundingBoxOptions) => any;
|
|
1160
|
+
geoPolygon: <K extends GeoPointFields<M> & string>(field: K, options: GeoPolygonOptions) => any;
|
|
1161
|
+
geoShape: <K extends GeoShapeFields<M> & string>(field: K, shape: Record<string, unknown>, options?: GeoShapeQueryOptions) => any; /** Distance-feature query — boost relevance by proximity of a date or geo_point field to an origin. */
|
|
1162
|
+
distanceFeature: <K extends (DateFields<M> | GeoPointFields<M>) & string>(field: K, options: DistanceFeatureOptions) => any; /** Rank-feature query — boost relevance using a numeric feature in a `rank_feature`/`rank_features` field. */
|
|
1163
|
+
rankFeature: <K extends RankFeatureFields<M> & string>(field: K, options?: RankFeatureQueryOptions) => any; /** Sparse-vector query — score with token-weight pairs from a learned sparse model (e.g. ELSER). */
|
|
1164
|
+
sparseVector: <K extends SparseVectorFields<M> & string>(field: K, options: SparseVectorQueryOptions) => any;
|
|
1165
|
+
/**
|
|
1166
|
+
* Script query — executes a Painless script to filter documents.
|
|
1167
|
+
*
|
|
1168
|
+
* **Security:** the `source` string is executed as Painless on the Elasticsearch cluster.
|
|
1169
|
+
* Never derive `source` from untrusted user input — use `params` to pass runtime values safely instead.
|
|
1170
|
+
*/
|
|
1171
|
+
script: (options: ScriptQueryOptions) => any;
|
|
1172
|
+
combinedFields: <K extends TextFields<M> & string>(fields: K[], query: string, options?: CombinedFieldsOptions) => any;
|
|
1173
|
+
/**
|
|
1174
|
+
* Query string query — parses a Lucene query syntax string.
|
|
1175
|
+
*
|
|
1176
|
+
* **Security:** if `query` is derived from untrusted user input, field-level access control and
|
|
1177
|
+
* syntax errors may expose internal field names or cause unexpected query behaviour.
|
|
1178
|
+
* Prefer `simpleQueryString` for user-facing search boxes — it silently ignores invalid syntax.
|
|
1179
|
+
*/
|
|
1180
|
+
queryString: (query: string, options?: QueryStringOptions) => any;
|
|
1181
|
+
/**
|
|
1182
|
+
* Simple query string query — a safer Lucene subset for user-facing search.
|
|
1183
|
+
*
|
|
1184
|
+
* **Security:** invalid syntax is silently ignored rather than returning an error.
|
|
1185
|
+
* Still constrain which fields are searched via `options.fields` to avoid exposing sensitive fields.
|
|
1186
|
+
*/
|
|
1187
|
+
simpleQueryString: (query: string, options?: SimpleQueryStringOptions) => any;
|
|
1188
|
+
moreLikeThis: (fields: Array<(TextFields<M> | KeywordFields<M>) & string>, like: string | Array<string | {
|
|
1189
|
+
_index: string;
|
|
1190
|
+
_id: string;
|
|
1191
|
+
}>, options?: MoreLikeThisOptions) => any;
|
|
1192
|
+
matchBoolPrefix: <K extends TextFields<M> & string>(field: K, value: string, options?: MatchBoolPrefixOptions) => any;
|
|
1193
|
+
/**
|
|
1194
|
+
* Conditionally execute a clause. Returns the clause DSL when `condition` is truthy, `undefined` otherwise.
|
|
1195
|
+
* The parent bool method (`must`, `filter`, etc.) treats `undefined` as a no-op — no empty arrays are emitted.
|
|
1196
|
+
*
|
|
1197
|
+
* `condition` is resolved as follows: functions are called, booleans are used as-is,
|
|
1198
|
+
* and any other value is checked for nullishness (`!= null`) — so `0` and `''` are truthy.
|
|
1199
|
+
*
|
|
1200
|
+
* **Note:** TypeScript cannot narrow closure variables inside callbacks, so values typed as `T | undefined`
|
|
1201
|
+
* still require a non-null assertion (`!`) inside the callback even when `condition` guarantees they are defined:
|
|
1202
|
+
* ```ts
|
|
1203
|
+
* .must(q => q.when(searchTerm, q => q.match('name', searchTerm!)))
|
|
1204
|
+
* ```
|
|
1205
|
+
*/
|
|
1206
|
+
/**
|
|
1207
|
+
* Nested query inside a clause context — use inside `must`, `filter`, `should`, or `mustNot`.
|
|
1208
|
+
*
|
|
1209
|
+
* ```ts
|
|
1210
|
+
* queryBuilder(m).bool().filter(q => q.nested('variants', qn => qn.term('color', 'red')))
|
|
1211
|
+
* ```
|
|
1212
|
+
*/
|
|
1213
|
+
nested: <K extends NestedPathFields<M> & string>(path: K, fn: (q: ClauseBuilder<SubFieldsOf<M, K>>) => any, options?: NestedOptions) => any; /** Function score query — wraps an inner query and applies scoring functions (field_value_factor, decay, script_score, etc.). */
|
|
1214
|
+
functionScore: (query: (q: ClauseBuilder<M>) => any, options?: FunctionScoreOptions) => any; /** Has-child query — returns parent documents whose child documents match the inner query. */
|
|
1215
|
+
hasChild: (type: string, query: (q: ClauseBuilder<M>) => any, options?: HasChildOptions) => any; /** Has-parent query — returns child documents whose parent document matches the inner query. */
|
|
1216
|
+
hasParent: (type: string, query: (q: ClauseBuilder<M>) => any, options?: HasParentOptions) => any; /** Parent-ID query — returns child documents joined to a specific parent document. */
|
|
1217
|
+
parentId: (type: string, id: string, options?: ParentIdOptions) => any; /** Intervals query — returns documents based on the order and proximity of matching terms. */
|
|
1218
|
+
intervals: <K extends TextFields<M> & string>(field: K, options: IntervalsOptions) => any; /** Span term — matches a single term; the building block for other span queries. */
|
|
1219
|
+
spanTerm: <K extends TextFields<M> & string>(field: K, value: string) => any; /** Span near — matches spans that are near one another. */
|
|
1220
|
+
spanNear: (clauses: ReadonlyArray<SpanQuery>, options?: SpanNearOptions) => any; /** Span or — matches the union of its span clauses. */
|
|
1221
|
+
spanOr: (clauses: ReadonlyArray<SpanQuery>) => any; /** Span not — removes matches that overlap with another span query. */
|
|
1222
|
+
spanNot: (include: SpanQuery, exclude: SpanQuery, options?: SpanNotOptions) => any; /** Span first — matches spans near the beginning of a field. */
|
|
1223
|
+
spanFirst: (match: SpanQuery, end: number) => any; /** Span containing — returns matches from `big` that contain a match from `little`. */
|
|
1224
|
+
spanContaining: (big: SpanQuery, little: SpanQuery) => any; /** Span within — returns matches from `little` that fall within `big`. */
|
|
1225
|
+
spanWithin: (big: SpanQuery, little: SpanQuery) => any; /** Span multi-term — wraps a multi-term query (wildcard, fuzzy, prefix, range, or regexp) as a span query. */
|
|
1226
|
+
spanMultiTerm: (query: Record<string, unknown>) => any; /** Span field masking — allows queries on different fields to be combined. */
|
|
1227
|
+
spanFieldMasking: (field: string, query: SpanQuery) => any;
|
|
1228
|
+
when: (condition: unknown, thenFn: (q: ClauseBuilder<M>) => any) => any | undefined;
|
|
1229
|
+
};
|
|
1230
|
+
type QueryBuilder<M extends Record<string, FieldTypeString>> = {
|
|
1231
|
+
bool: () => QueryBuilder<M>;
|
|
1232
|
+
must: (fn: (q: ClauseBuilder<M>) => any) => QueryBuilder<M>;
|
|
1233
|
+
mustNot: (fn: (q: ClauseBuilder<M>) => any) => QueryBuilder<M>;
|
|
1234
|
+
should: (fn: (q: ClauseBuilder<M>) => any) => QueryBuilder<M>;
|
|
1235
|
+
filter: (fn: (q: ClauseBuilder<M>) => any) => QueryBuilder<M>;
|
|
1236
|
+
minimumShouldMatch: (n: number) => QueryBuilder<M>;
|
|
1237
|
+
matchAll: () => QueryBuilder<M>;
|
|
1238
|
+
matchNone: () => QueryBuilder<M>;
|
|
1239
|
+
match: <K extends TextFields<M> & string>(field: K, value: string, options?: MatchOptions) => QueryBuilder<M>;
|
|
1240
|
+
multiMatch: <K extends TextFields<M> & string>(fields: K[], value: string, options?: MultiMatchOptions) => QueryBuilder<M>;
|
|
1241
|
+
matchPhrase: <K extends TextFields<M> & string>(field: K, value: string) => QueryBuilder<M>;
|
|
1242
|
+
matchPhrasePrefix: <K extends TextFields<M> & string>(field: K, value: string, options?: MatchPhrasePrefixOptions) => QueryBuilder<M>;
|
|
1243
|
+
term: <K extends TermableFields<M> & string>(field: K, value: Val<M, K>) => QueryBuilder<M>;
|
|
1244
|
+
terms: <K extends TermableFields<M> & string>(field: K, values: Array<Val<M, K>>) => QueryBuilder<M>;
|
|
1245
|
+
range: <K extends RangeableFields<M> & string>(field: K, conditions: {
|
|
1246
|
+
gte?: Val<M, K>;
|
|
1247
|
+
lte?: Val<M, K>;
|
|
1248
|
+
gt?: Val<M, K>;
|
|
1249
|
+
lt?: Val<M, K>;
|
|
1250
|
+
}) => QueryBuilder<M>;
|
|
1251
|
+
exists: (field: string & keyof M) => QueryBuilder<M>;
|
|
1252
|
+
prefix: <K extends KeywordFields<M> & string>(field: K, value: string) => QueryBuilder<M>;
|
|
1253
|
+
wildcard: <K extends KeywordFields<M> & string>(field: K, value: string) => QueryBuilder<M>;
|
|
1254
|
+
fuzzy: <K extends FuzzyableFields<M> & string>(field: K, value: string, options?: FuzzyOptions) => QueryBuilder<M>;
|
|
1255
|
+
ids: (values: string[]) => QueryBuilder<M>;
|
|
1256
|
+
/**
|
|
1257
|
+
* Nested query — for querying fields mapped as `nested()`.
|
|
1258
|
+
*
|
|
1259
|
+
* Each nested object is stored as a separate hidden document. The `.nested()` wrapper
|
|
1260
|
+
* is required for Elasticsearch to search those hidden documents correctly. Without it,
|
|
1261
|
+
* queries against nested sub-fields will return no results.
|
|
1262
|
+
*
|
|
1263
|
+
* The inner callback receives a typed `ClauseBuilder` constrained to the sub-fields of
|
|
1264
|
+
* `path`, so field names and value types are checked at compile time.
|
|
1265
|
+
*
|
|
1266
|
+
* For `object()` fields, no wrapper is needed — query sub-fields directly with dot-notation
|
|
1267
|
+
* (e.g. `.term('address.city', 'NYC')`).
|
|
1268
|
+
*/
|
|
1269
|
+
nested: <K extends NestedPathFields<M> & string>(path: K, fn: (q: ClauseBuilder<SubFieldsOf<M, K>>) => any, options?: NestedOptions) => QueryBuilder<M>;
|
|
1270
|
+
knn: <K extends DenseVectorFields<M> & string>(field: K, queryVector: number[], options: KnnOptions) => QueryBuilder<M>;
|
|
1271
|
+
/**
|
|
1272
|
+
* Script query — executes a Painless script to filter documents.
|
|
1273
|
+
*
|
|
1274
|
+
* **Security:** the `source` string is executed as Painless on the Elasticsearch cluster.
|
|
1275
|
+
* Never derive `source` from untrusted user input — use `params` to pass runtime values safely instead.
|
|
1276
|
+
*/
|
|
1277
|
+
script: (options: ScriptQueryOptions) => QueryBuilder<M>;
|
|
1278
|
+
/**
|
|
1279
|
+
* Script score query — wraps an inner query and rescores results using a Painless script.
|
|
1280
|
+
*
|
|
1281
|
+
* **Security:** the `source` string is executed as Painless on the Elasticsearch cluster.
|
|
1282
|
+
* Never derive `source` from untrusted user input — use `params` to pass runtime values safely instead.
|
|
1283
|
+
*/
|
|
1284
|
+
scriptScore: (query: (q: ClauseBuilder<M>) => any, script: ScriptOptions, options?: ScriptScoreOptions) => QueryBuilder<M>;
|
|
1285
|
+
percolate: (options: PercolateOptions) => QueryBuilder<M>; /** Function score query — wraps an inner query and applies scoring functions (field_value_factor, decay, script_score, etc.). */
|
|
1286
|
+
functionScore: (query: (q: ClauseBuilder<M>) => any, options?: FunctionScoreOptions) => QueryBuilder<M>; /** Has-child query — returns parent documents whose child documents match the inner query. */
|
|
1287
|
+
hasChild: (type: string, query: (q: ClauseBuilder<M>) => any, options?: HasChildOptions) => QueryBuilder<M>; /** Has-parent query — returns child documents whose parent document matches the inner query. */
|
|
1288
|
+
hasParent: (type: string, query: (q: ClauseBuilder<M>) => any, options?: HasParentOptions) => QueryBuilder<M>; /** Parent-ID query — returns child documents joined to a specific parent document. */
|
|
1289
|
+
parentId: (type: string, id: string, options?: ParentIdOptions) => QueryBuilder<M>; /** Intervals query — returns documents based on the order and proximity of matching terms. */
|
|
1290
|
+
intervals: <K extends TextFields<M> & string>(field: K, options: IntervalsOptions) => QueryBuilder<M>; /** Span term — matches a single term; the building block for other span queries. */
|
|
1291
|
+
spanTerm: <K extends TextFields<M> & string>(field: K, value: string) => QueryBuilder<M>; /** Span near — matches spans that are near one another. */
|
|
1292
|
+
spanNear: (clauses: ReadonlyArray<SpanQuery>, options?: SpanNearOptions) => QueryBuilder<M>; /** Span or — matches the union of its span clauses. */
|
|
1293
|
+
spanOr: (clauses: ReadonlyArray<SpanQuery>) => QueryBuilder<M>; /** Span not — removes matches that overlap with another span query. */
|
|
1294
|
+
spanNot: (include: SpanQuery, exclude: SpanQuery, options?: SpanNotOptions) => QueryBuilder<M>; /** Span first — matches spans near the beginning of a field. */
|
|
1295
|
+
spanFirst: (match: SpanQuery, end: number) => QueryBuilder<M>; /** Span containing — returns matches from `big` that contain a match from `little`. */
|
|
1296
|
+
spanContaining: (big: SpanQuery, little: SpanQuery) => QueryBuilder<M>; /** Span within — returns matches from `little` that fall within `big`. */
|
|
1297
|
+
spanWithin: (big: SpanQuery, little: SpanQuery) => QueryBuilder<M>; /** Span multi-term — wraps a multi-term query (wildcard, fuzzy, prefix, range, or regexp) as a span query. */
|
|
1298
|
+
spanMultiTerm: (query: Record<string, unknown>) => QueryBuilder<M>; /** Span field masking — allows queries on different fields to be combined. */
|
|
1299
|
+
spanFieldMasking: (field: string, query: SpanQuery) => QueryBuilder<M>;
|
|
1300
|
+
/**
|
|
1301
|
+
* Conditionally apply a branch to the query chain. Returns the result of `thenFn` when `condition` is truthy,
|
|
1302
|
+
* otherwise returns the current builder unchanged — the chain is never broken.
|
|
1303
|
+
*
|
|
1304
|
+
* `condition` is resolved as follows: functions are called, booleans are used as-is,
|
|
1305
|
+
* and any other value is checked for nullishness (`!= null`) — so `0` and `''` are truthy.
|
|
1306
|
+
*
|
|
1307
|
+
* **Note:** TypeScript cannot narrow closure variables inside callbacks, so values typed as `T | undefined`
|
|
1308
|
+
* still require a non-null assertion (`!`) inside the callback even when `condition` guarantees they are defined:
|
|
1309
|
+
* ```ts
|
|
1310
|
+
* queryBuilder(m).bool()
|
|
1311
|
+
* .when(searchTerm, q => q.must(q2 => q2.match('name', searchTerm!)))
|
|
1312
|
+
* .when(minPrice, q => q.filter(q2 => q2.range('price', { gte: minPrice! })))
|
|
1313
|
+
* .build()
|
|
1314
|
+
* ```
|
|
1315
|
+
*/
|
|
1316
|
+
when: (condition: unknown, thenFn: (q: QueryBuilder<M>) => QueryBuilder<M>) => QueryBuilder<M>;
|
|
1317
|
+
aggs: (fn: (agg: RootAggregationBuilder<M>) => RootAggregationBuilder<M>) => QueryBuilder<M>;
|
|
1318
|
+
suggest: (fn: (s: SuggesterBuilder<M>) => SuggesterBuilder<M>) => QueryBuilder<M>;
|
|
1319
|
+
sort: (field: (SortableFields<M> & string) | '_score' | '_doc', direction: 'asc' | 'desc') => QueryBuilder<M>;
|
|
1320
|
+
from: (from: number) => QueryBuilder<M>;
|
|
1321
|
+
size: (size: number) => QueryBuilder<M>;
|
|
1322
|
+
_source: (fields: Array<string & keyof M>) => QueryBuilder<M>; /** Include-only subset for `_source` filtering (paths may use wildcards). */
|
|
1323
|
+
sourceIncludes: (paths: string[]) => QueryBuilder<M>; /** Exclude subset for `_source` filtering (paths may use wildcards). */
|
|
1324
|
+
sourceExcludes: (paths: string[]) => QueryBuilder<M>; /** Runtime mappings — define script-computed fields available to the query, sorts, and aggs. */
|
|
1325
|
+
runtimeMappings: (mappings: Record<string, MappingRuntimeField>) => QueryBuilder<M>; /** Retrieve doc-values for the specified fields in the hit response. */
|
|
1326
|
+
docValueFields: (fields: Array<QueryDslFieldAndFormat | string>) => QueryBuilder<M>; /** Retrieve values via the fields API (supports runtime + standard fields with format). */
|
|
1327
|
+
fields: (fields: Array<QueryDslFieldAndFormat | string>) => QueryBuilder<M>; /** Post-filter — applied after aggregations, so aggs see the unfiltered result set. */
|
|
1328
|
+
postFilter: (fn: (q: ClauseBuilder<M>) => any) => QueryBuilder<M>; /** Script fields — compute per-hit values via Painless scripts. */
|
|
1329
|
+
scriptFields: (fields: Record<string, ScriptField>) => QueryBuilder<M>;
|
|
1330
|
+
timeout: (timeout: string) => QueryBuilder<M>;
|
|
1331
|
+
trackScores: (track: boolean) => QueryBuilder<M>;
|
|
1332
|
+
explain: (explain: boolean) => QueryBuilder<M>;
|
|
1333
|
+
minScore: (score: number) => QueryBuilder<M>;
|
|
1334
|
+
version: (version: boolean) => QueryBuilder<M>;
|
|
1335
|
+
seqNoPrimaryTerm: (enabled: boolean) => QueryBuilder<M>;
|
|
1336
|
+
trackTotalHits: (value: boolean | number) => QueryBuilder<M>;
|
|
1337
|
+
highlight: (fields: Array<HighlightableFields<M> & string>, options?: HighlightOptions) => QueryBuilder<M>;
|
|
1338
|
+
geoDistance: <K extends GeoPointFields<M> & string>(field: K, center: {
|
|
1339
|
+
lat: number;
|
|
1340
|
+
lon: number;
|
|
1341
|
+
}, options: GeoDistanceOptions) => QueryBuilder<M>;
|
|
1342
|
+
geoBoundingBox: <K extends GeoPointFields<M> & string>(field: K, options: GeoBoundingBoxOptions) => QueryBuilder<M>;
|
|
1343
|
+
geoPolygon: <K extends GeoPointFields<M> & string>(field: K, options: GeoPolygonOptions) => QueryBuilder<M>;
|
|
1344
|
+
geoShape: <K extends GeoShapeFields<M> & string>(field: K, shape: Record<string, unknown>, options?: GeoShapeQueryOptions) => QueryBuilder<M>; /** Distance-feature query — boost relevance by proximity of a date or geo_point field to an origin. */
|
|
1345
|
+
distanceFeature: <K extends (DateFields<M> | GeoPointFields<M>) & string>(field: K, options: DistanceFeatureOptions) => QueryBuilder<M>; /** Rank-feature query — boost relevance using a numeric feature in a `rank_feature`/`rank_features` field. */
|
|
1346
|
+
rankFeature: <K extends RankFeatureFields<M> & string>(field: K, options?: RankFeatureQueryOptions) => QueryBuilder<M>; /** Sparse-vector query — score with token-weight pairs from a learned sparse model (e.g. ELSER). */
|
|
1347
|
+
sparseVector: <K extends SparseVectorFields<M> & string>(field: K, options: SparseVectorQueryOptions) => QueryBuilder<M>;
|
|
1348
|
+
regexp: <K extends KeywordFields<M> & string>(field: K, value: string, options?: RegexpOptions) => QueryBuilder<M>;
|
|
1349
|
+
constantScore: (fn: (q: ClauseBuilder<M>) => any, options?: ConstantScoreOptions) => QueryBuilder<M>;
|
|
1350
|
+
combinedFields: <K extends TextFields<M> & string>(fields: K[], query: string, options?: CombinedFieldsOptions) => QueryBuilder<M>;
|
|
1351
|
+
/**
|
|
1352
|
+
* Query string query — parses a Lucene query syntax string.
|
|
1353
|
+
*
|
|
1354
|
+
* **Security:** if `query` is derived from untrusted user input, field-level access control and
|
|
1355
|
+
* syntax errors may expose internal field names or cause unexpected query behaviour.
|
|
1356
|
+
* Prefer `simpleQueryString` for user-facing search boxes — it silently ignores invalid syntax.
|
|
1357
|
+
*/
|
|
1358
|
+
queryString: (query: string, options?: QueryStringOptions) => QueryBuilder<M>;
|
|
1359
|
+
/**
|
|
1360
|
+
* Simple query string query — a safer Lucene subset for user-facing search.
|
|
1361
|
+
*
|
|
1362
|
+
* **Security:** invalid syntax is silently ignored rather than returning an error.
|
|
1363
|
+
* Still constrain which fields are searched via `options.fields` to avoid exposing sensitive fields.
|
|
1364
|
+
*/
|
|
1365
|
+
simpleQueryString: (query: string, options?: SimpleQueryStringOptions) => QueryBuilder<M>;
|
|
1366
|
+
moreLikeThis: (fields: Array<(TextFields<M> | KeywordFields<M>) & string>, like: string | Array<string | {
|
|
1367
|
+
_index: string;
|
|
1368
|
+
_id: string;
|
|
1369
|
+
}>, options?: MoreLikeThisOptions) => QueryBuilder<M>;
|
|
1370
|
+
matchBoolPrefix: <K extends TextFields<M> & string>(field: K, value: string, options?: MatchBoolPrefixOptions) => QueryBuilder<M>;
|
|
1371
|
+
searchAfter: (values: SortResults) => QueryBuilder<M>;
|
|
1372
|
+
preference: (value: string) => QueryBuilder<M>;
|
|
1373
|
+
collapse: (field: CollapsibleFields<M> & string, options?: {
|
|
1374
|
+
inner_hits?: SearchInnerHits;
|
|
1375
|
+
max_concurrent_group_searches?: number;
|
|
1376
|
+
}) => QueryBuilder<M>;
|
|
1377
|
+
rescore: (queryFn: (q: ClauseBuilder<M>) => any, windowSize: number, options?: {
|
|
1378
|
+
query_weight?: number;
|
|
1379
|
+
rescore_query_weight?: number;
|
|
1380
|
+
score_mode?: 'total' | 'multiply' | 'avg' | 'max' | 'min';
|
|
1381
|
+
}) => QueryBuilder<M>;
|
|
1382
|
+
storedFields: (fields: Array<string>) => QueryBuilder<M>;
|
|
1383
|
+
terminateAfter: (count: number) => QueryBuilder<M>;
|
|
1384
|
+
pit: (id: string, keepAlive: string) => QueryBuilder<M>;
|
|
1385
|
+
indicesBoost: (boosts: Array<Record<string, number>>) => QueryBuilder<M>;
|
|
1386
|
+
build: () => QueryState<M>;
|
|
1387
|
+
};
|
|
1388
|
+
//#endregion
|
|
1389
|
+
//#region src/aggregation.builder.d.ts
|
|
1390
|
+
declare const aggregations: <M extends Record<string, FieldTypeString>>(_schema: MappingsSchema<M>) => RootAggregationBuilder<M>;
|
|
1391
|
+
//#endregion
|
|
1392
|
+
//#region src/mapping.builder.d.ts
|
|
1393
|
+
type UnionToIntersection<U> = (U extends unknown ? (x: U) => never : never) extends ((x: infer I) => never) ? I : never;
|
|
1394
|
+
type FlattenSubFields<Prefix extends string, F extends Record<string, FieldMappingWithLiteralType>> = UnionToIntersection<{ [K in keyof F & string]: { [Key in `${Prefix}.${K}`]: F[K]['type'] } & (F[K] extends {
|
|
1395
|
+
_subFields: infer Sub extends Record<string, FieldMappingWithLiteralType>;
|
|
1396
|
+
} ? FlattenSubFields<`${Prefix}.${K}`, Sub> : Record<never, never>) }[keyof F & string]>;
|
|
1397
|
+
type FlattenMultiFields<Prefix extends string, MF extends Record<string, FieldMappingWithLiteralType>> = UnionToIntersection<{ [K in keyof MF & string]: { [Key in `${Prefix}.${K}`]: MF[K]['type'] } }[keyof MF & string]>;
|
|
1398
|
+
type ExtractFieldTypes<F extends Record<string, FieldMappingWithLiteralType>> = { [K in keyof F]: F[K]['type'] } & UnionToIntersection<{ [K in keyof F & string]: (F[K] extends {
|
|
1399
|
+
_subFields: infer Sub extends Record<string, FieldMappingWithLiteralType>;
|
|
1400
|
+
} ? FlattenSubFields<K, Sub> : Record<never, never>) & (F[K] extends {
|
|
1401
|
+
_multiFields: infer MF extends Record<string, FieldMappingWithLiteralType>;
|
|
1402
|
+
} ? FlattenMultiFields<K, MF> : Record<never, never>) }[keyof F & string]>;
|
|
1403
|
+
declare const mappings: <F extends Record<string, FieldMappingWithLiteralType>>(fields: F, options?: MappingOptions) => MappingsSchema<ExtractFieldTypes<F>, F>;
|
|
1404
|
+
//#endregion
|
|
1405
|
+
//#region src/field.helpers.d.ts
|
|
1406
|
+
declare const text: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: TextFieldOptions<MF>) => TextFieldMapping & Readonly<{
|
|
1407
|
+
_multiFields: MF;
|
|
1408
|
+
}>;
|
|
1409
|
+
declare const keyword: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: KeywordFieldOptions<MF>) => KeywordFieldMapping & Readonly<{
|
|
1410
|
+
_multiFields: MF;
|
|
1411
|
+
}>;
|
|
1412
|
+
declare const long: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => LongFieldMapping & Readonly<{
|
|
1413
|
+
_multiFields: MF;
|
|
1414
|
+
}>;
|
|
1415
|
+
declare const integer: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => IntegerFieldMapping & Readonly<{
|
|
1416
|
+
_multiFields: MF;
|
|
1417
|
+
}>;
|
|
1418
|
+
declare const short: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => ShortFieldMapping & Readonly<{
|
|
1419
|
+
_multiFields: MF;
|
|
1420
|
+
}>;
|
|
1421
|
+
declare const byte: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => ByteFieldMapping & Readonly<{
|
|
1422
|
+
_multiFields: MF;
|
|
1423
|
+
}>;
|
|
1424
|
+
declare const double: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => DoubleFieldMapping & Readonly<{
|
|
1425
|
+
_multiFields: MF;
|
|
1426
|
+
}>;
|
|
1427
|
+
declare const float: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => FloatFieldMapping & Readonly<{
|
|
1428
|
+
_multiFields: MF;
|
|
1429
|
+
}>;
|
|
1430
|
+
declare const halfFloat: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => HalfFloatFieldMapping & Readonly<{
|
|
1431
|
+
_multiFields: MF;
|
|
1432
|
+
}>;
|
|
1433
|
+
declare const scaledFloat: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: ScaledFloatFieldOptions<MF>) => ScaledFloatFieldMapping & Readonly<{
|
|
1434
|
+
_multiFields: MF;
|
|
1435
|
+
}>;
|
|
1436
|
+
declare const date: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: DateFieldOptions<MF>) => DateFieldMapping & Readonly<{
|
|
1437
|
+
_multiFields: MF;
|
|
1438
|
+
}>;
|
|
1439
|
+
/**
|
|
1440
|
+
* Date field stored with nanosecond precision. Same API as `date()` but supports sub-millisecond timestamps.
|
|
1441
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/date_nanos.html
|
|
1442
|
+
*/
|
|
1443
|
+
declare const dateNanos: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: DateNanosFieldOptions<MF>) => DateNanosFieldMapping & Readonly<{
|
|
1444
|
+
_multiFields: MF;
|
|
1445
|
+
}>;
|
|
1446
|
+
declare const boolean: (options?: BooleanFieldOptions) => BooleanFieldMapping;
|
|
1447
|
+
declare const binary: () => BinaryFieldMapping;
|
|
1448
|
+
declare const ip: (options?: IpFieldOptions) => IpFieldMapping;
|
|
1449
|
+
declare const denseVector: (options?: DenseVectorFieldOptions) => DenseVectorFieldMapping;
|
|
1450
|
+
/**
|
|
1451
|
+
* Quantized dense vector field — wraps `denseVector()` with `int8_hnsw` index type.
|
|
1452
|
+
*
|
|
1453
|
+
* Quantizes float32 vectors to int8 at index time, saving ~75% memory.
|
|
1454
|
+
* Recommended for vectors with dims >= 384. Original float vectors are retained
|
|
1455
|
+
* in the index, enabling a two-phase search pattern:
|
|
1456
|
+
*
|
|
1457
|
+
* 1. Fast approximate search using quantized int8 vectors
|
|
1458
|
+
* 2. Precise rescore of top-k results using retained float vectors
|
|
1459
|
+
*
|
|
1460
|
+
* @example
|
|
1461
|
+
* // Index mapping
|
|
1462
|
+
* const schema = mappings({
|
|
1463
|
+
* title: text(),
|
|
1464
|
+
* embedding: quantizedDenseVector({ dims: 768, similarity: 'cosine' }),
|
|
1465
|
+
* }, {
|
|
1466
|
+
* _source: { excludes: ['embedding'] },
|
|
1467
|
+
* });
|
|
1468
|
+
*
|
|
1469
|
+
* // Two-phase search: fast kNN + precise rescore
|
|
1470
|
+
* const result = queryBuilder(schema)
|
|
1471
|
+
* .knn('embedding', queryVector, { k: 100, num_candidates: 200 })
|
|
1472
|
+
* .rescore(
|
|
1473
|
+
* (q) => q.scriptScore(
|
|
1474
|
+
* (inner) => inner.matchAll(),
|
|
1475
|
+
* { source: "cosineSimilarity(params.v, 'embedding') + 1.0", params: { v: queryVector } }
|
|
1476
|
+
* ),
|
|
1477
|
+
* 100
|
|
1478
|
+
* )
|
|
1479
|
+
* .build();
|
|
1480
|
+
*/
|
|
1481
|
+
declare const quantizedDenseVector: (options?: DenseVectorFieldOptions) => DenseVectorFieldMapping;
|
|
1482
|
+
/**
|
|
1483
|
+
* Sparse vector field — stores token-weight pairs for sparse retrieval (e.g. ELSER/BM25-style models).
|
|
1484
|
+
* Complement to `denseVector()`. Query with the `sparse_vector` query.
|
|
1485
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sparse-vector.html
|
|
1486
|
+
*/
|
|
1487
|
+
declare const sparseVector: () => SparseVectorFieldMapping;
|
|
1488
|
+
/**
|
|
1489
|
+
* Rank feature field — a single numeric feature used by the `rank_feature` query to boost relevance.
|
|
1490
|
+
* Use when each document has one named signal (e.g. `pagerank`, `popularity_score`).
|
|
1491
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rank-feature.html
|
|
1492
|
+
*/
|
|
1493
|
+
declare const rankFeature: (options?: RankFeatureFieldOptions) => RankFeatureFieldMapping;
|
|
1494
|
+
/**
|
|
1495
|
+
* Rank features field — a sparse map of numeric features used by the `rank_feature` query.
|
|
1496
|
+
* Use when each document has many named signals (e.g. topic scores).
|
|
1497
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rank-features.html
|
|
1498
|
+
*/
|
|
1499
|
+
declare const rankFeatures: (options?: RankFeaturesFieldOptions) => RankFeaturesFieldMapping;
|
|
1500
|
+
/**
|
|
1501
|
+
* Semantic text field (ES 9.x) — ML-powered text field for semantic and hybrid search.
|
|
1502
|
+
* Automatically generates and stores embeddings at index time using the configured inference endpoint.
|
|
1503
|
+
*
|
|
1504
|
+
* @example
|
|
1505
|
+
* const schema = mappings({
|
|
1506
|
+
* title: text(),
|
|
1507
|
+
* body: semanticText({ inference_id: 'my-elser-endpoint' }),
|
|
1508
|
+
* });
|
|
1509
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-text.html
|
|
1510
|
+
*/
|
|
1511
|
+
declare const semanticText: (options?: SemanticTextFieldOptions) => SemanticTextFieldMapping;
|
|
1512
|
+
/**
|
|
1513
|
+
* Unsigned long field (ES 9.0+) — stores unsigned 64-bit integer values (0 to 2^64-1).
|
|
1514
|
+
* Use when values exceed the `long` range.
|
|
1515
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html
|
|
1516
|
+
*/
|
|
1517
|
+
declare const unsignedLong: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: UnsignedLongFieldOptions<MF>) => UnsignedLongFieldMapping & Readonly<{
|
|
1518
|
+
_multiFields: MF;
|
|
1519
|
+
}>;
|
|
1520
|
+
declare const geoPoint: (options?: GeoPointFieldOptions) => GeoPointFieldMapping;
|
|
1521
|
+
declare const geoShape: (options?: GeoShapeFieldOptions) => GeoShapeFieldMapping;
|
|
1522
|
+
declare const completion: (options?: CompletionFieldOptions) => CompletionFieldMapping;
|
|
1523
|
+
/**
|
|
1524
|
+
* Object field — for JSON-like structured documents where sub-fields are queried with dot-notation.
|
|
1525
|
+
*
|
|
1526
|
+
* The most common way to model structured data (e.g. `{ address: { city, zip } }`).
|
|
1527
|
+
* Sub-fields are indexed inline within the parent document — no special query wrapper needed.
|
|
1528
|
+
* Query sub-fields directly using dot-notation: `.term('address.city', 'NYC')`.
|
|
1529
|
+
*
|
|
1530
|
+
* Use `nested()` instead when you have **arrays of objects** and need cross-field queries
|
|
1531
|
+
* within each element to be accurate (e.g. tags with both a label and weight).
|
|
1532
|
+
*
|
|
1533
|
+
* @example
|
|
1534
|
+
* const m = mappings({
|
|
1535
|
+
* address: object({
|
|
1536
|
+
* street: text(),
|
|
1537
|
+
* city: keyword(),
|
|
1538
|
+
* zip: keyword(),
|
|
1539
|
+
* }),
|
|
1540
|
+
* });
|
|
1541
|
+
* queryBuilder(m).term('address.city', 'NYC').build();
|
|
1542
|
+
*/
|
|
1543
|
+
declare function object<F extends Record<string, FieldMappingWithLiteralType>>(fields: F, options?: ObjectFieldOptions): TypedObjectFieldMapping<F>;
|
|
1544
|
+
/**
|
|
1545
|
+
* Nested field — for **arrays of objects** where cross-field queries within each element must be accurate.
|
|
1546
|
+
*
|
|
1547
|
+
* Each nested object is stored as a separate hidden Elasticsearch document, preserving the
|
|
1548
|
+
* relationship between sub-fields within each element. Without `nested`, Elasticsearch flattens
|
|
1549
|
+
* array sub-fields and loses which values belong to the same element.
|
|
1550
|
+
*
|
|
1551
|
+
* Queries on nested fields **must** use the `.nested()` query builder method — direct dot-notation
|
|
1552
|
+
* queries will not find nested documents.
|
|
1553
|
+
*
|
|
1554
|
+
* Use `object()` instead for single structured objects (addresses, names, etc.) — it is simpler,
|
|
1555
|
+
* more efficient, and does not require a query wrapper.
|
|
1556
|
+
*
|
|
1557
|
+
* @example
|
|
1558
|
+
* const m = mappings({
|
|
1559
|
+
* tags: nested({
|
|
1560
|
+
* label: keyword(),
|
|
1561
|
+
* weight: float(),
|
|
1562
|
+
* }),
|
|
1563
|
+
* });
|
|
1564
|
+
* queryBuilder(m).nested('tags', q => q.term('label', 'sale')).build();
|
|
1565
|
+
*/
|
|
1566
|
+
declare function nested<F extends Record<string, FieldMappingWithLiteralType>>(fields: F, options?: NestedFieldOptions): TypedNestedFieldMapping<F>;
|
|
1567
|
+
declare const alias: (options: AliasFieldOptions) => AliasFieldMapping;
|
|
1568
|
+
declare const percolator: () => PercolatorFieldMapping;
|
|
1569
|
+
declare const integerRange: (options?: RangeFieldOptions) => IntegerRangeFieldMapping;
|
|
1570
|
+
declare const floatRange: (options?: RangeFieldOptions) => FloatRangeFieldMapping;
|
|
1571
|
+
declare const longRange: (options?: RangeFieldOptions) => LongRangeFieldMapping;
|
|
1572
|
+
declare const doubleRange: (options?: RangeFieldOptions) => DoubleRangeFieldMapping;
|
|
1573
|
+
declare const dateRange: (options?: RangeFieldOptions) => DateRangeFieldMapping;
|
|
1574
|
+
/**
|
|
1575
|
+
* IP range field — stores a range of IPv4/IPv6 addresses.
|
|
1576
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/range.html
|
|
1577
|
+
*/
|
|
1578
|
+
declare const ipRange: (options?: IpRangeFieldOptions) => IpRangeFieldMapping;
|
|
1579
|
+
/**
|
|
1580
|
+
* No-score text field — faster and uses less disk than `text()`.
|
|
1581
|
+
* Use when you only need filter/match but not relevance scoring (e.g., logs, simple field matches).
|
|
1582
|
+
*/
|
|
1583
|
+
declare const matchOnlyText: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: MatchOnlyTextFieldOptions<MF>) => MatchOnlyTextFieldMapping & Readonly<{
|
|
1584
|
+
_multiFields: MF;
|
|
1585
|
+
}>;
|
|
1586
|
+
/**
|
|
1587
|
+
* Autocomplete / typeahead field. Creates sub-fields for edge n-gram matching
|
|
1588
|
+
* out of the box. Query with `multi_match` targeting the generated sub-fields.
|
|
1589
|
+
*/
|
|
1590
|
+
declare const searchAsYouType: (options?: SearchAsYouTypeFieldOptions) => SearchAsYouTypeFieldMapping;
|
|
1591
|
+
/**
|
|
1592
|
+
* Field where every document has the same value. Useful for multi-index queries
|
|
1593
|
+
* to identify the index type (e.g., `constantKeyword({ value: 'product' })`).
|
|
1594
|
+
*/
|
|
1595
|
+
declare const constantKeyword: (options?: ConstantKeywordFieldOptions) => ConstantKeywordFieldMapping;
|
|
1596
|
+
/**
|
|
1597
|
+
* Optimized for grep-like wildcard/regexp queries on high-cardinality or large fields.
|
|
1598
|
+
* Use instead of `keyword()` when leading wildcards (`*foo`) are needed.
|
|
1599
|
+
*/
|
|
1600
|
+
declare const wildcardField: (options?: WildcardFieldOptions) => WildcardFieldMapping;
|
|
1601
|
+
/**
|
|
1602
|
+
* Flattens complex/dynamic objects into a single field. Faster than `nested()`,
|
|
1603
|
+
* but only supports keyword-level queries on inner values.
|
|
1604
|
+
*/
|
|
1605
|
+
declare const flattened: (options?: FlattenedFieldOptions) => FlattenedFieldMapping;
|
|
1606
|
+
/**
|
|
1607
|
+
* Token count field — stores the number of tokens produced by an analyzer.
|
|
1608
|
+
* Useful for enforcing minimum/maximum field lengths via queries or aggregations.
|
|
1609
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/token-count.html
|
|
1610
|
+
*/
|
|
1611
|
+
declare const tokenCount: (options?: TokenCountFieldOptions) => TokenCountFieldMapping;
|
|
1612
|
+
/**
|
|
1613
|
+
* Murmur3 hash field — computes and stores a murmur3 hash of field values at index time.
|
|
1614
|
+
* Requires the `mapper-murmur3` plugin.
|
|
1615
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/plugins/current/mapper-murmur3.html
|
|
1616
|
+
*/
|
|
1617
|
+
declare const murmur3Hash: () => Murmur3FieldMapping;
|
|
1618
|
+
/**
|
|
1619
|
+
* Join field — defines parent/child relationships within a single index.
|
|
1620
|
+
* `relations` is required: maps parent names to one or more child names.
|
|
1621
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* const m = mappings({
|
|
1625
|
+
* title: text(),
|
|
1626
|
+
* relation: join({ relations: { question: 'answer' } }),
|
|
1627
|
+
* });
|
|
1628
|
+
*/
|
|
1629
|
+
declare const join: (options: JoinFieldOptions) => JoinFieldMapping;
|
|
1630
|
+
//#endregion
|
|
1631
|
+
//#region src/multi-search.types.d.ts
|
|
1632
|
+
/**
|
|
1633
|
+
* Request-level parameters for a multi-search request — mirrors the subset of
|
|
1634
|
+
* the official `MsearchRequest` type that is set at the top of the request
|
|
1635
|
+
* (rather than per-sub-search). The builder applies these via
|
|
1636
|
+
* `.withParams({...})` and exposes them on `.buildParams()` so callers can
|
|
1637
|
+
* spread them into `client.msearch({...params, body: ndjson})`.
|
|
1638
|
+
*/
|
|
1639
|
+
type MSearchRequestParams = Pick<MsearchRequest, 'max_concurrent_searches' | 'max_concurrent_shard_requests' | 'pre_filter_shard_size' | 'rest_total_hits_as_int' | 'typed_keys' | 'ccs_minimize_roundtrips' | 'search_type' | 'routing'>;
|
|
1640
|
+
/**
|
|
1641
|
+
* Header options for each search in a multi-search request — re-exported from official @elastic/elasticsearch types
|
|
1642
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html
|
|
1643
|
+
*/
|
|
1644
|
+
type MSearchHeader = MsearchMultisearchHeader;
|
|
1645
|
+
/**
|
|
1646
|
+
* A single search request in a multi-search operation
|
|
1647
|
+
*/
|
|
1648
|
+
type MSearchRequest<M extends Record<string, FieldTypeString>> = {
|
|
1649
|
+
/** Optional header for this search */header?: MSearchHeader; /** The query body */
|
|
1650
|
+
body: QueryState<M>;
|
|
1651
|
+
};
|
|
1652
|
+
/**
|
|
1653
|
+
* Multi-search builder interface
|
|
1654
|
+
*/
|
|
1655
|
+
type MSearchBuilder<M extends Record<string, FieldTypeString>> = {
|
|
1656
|
+
/** Add a search request with header and body */add: (request: MSearchRequest<M>) => MSearchBuilder<M>; /** Add a search using a pre-built query state */
|
|
1657
|
+
addQuery: (body: QueryState<M>, header?: MSearchHeader) => MSearchBuilder<M>; /** Add a search using a QueryBuilder directly — convenience over `.addQuery(qb.build(), header)` */
|
|
1658
|
+
addQueryBuilder: (qb: QueryBuilder<M>, header?: MSearchHeader) => MSearchBuilder<M>; /** Set request-level params (e.g. `max_concurrent_searches`, `typed_keys`). Merges with any previously set params. */
|
|
1659
|
+
withParams: (params: MSearchRequestParams) => MSearchBuilder<M>; /** Build as NDJSON string format for Elasticsearch */
|
|
1660
|
+
build: () => string; /** Build as array of objects (header, body pairs) */
|
|
1661
|
+
buildArray: () => Array<MSearchHeader | QueryState<M>>; /** Return the request-level params set via `.withParams()`, for spreading into `client.msearch()`. */
|
|
1662
|
+
buildParams: () => MSearchRequestParams;
|
|
1663
|
+
};
|
|
1664
|
+
//#endregion
|
|
1665
|
+
//#region src/multi-search.builder.d.ts
|
|
1666
|
+
/**
|
|
1667
|
+
* Create a new multi-search builder
|
|
1668
|
+
* @example
|
|
1669
|
+
* const ms = msearch(productMappings)
|
|
1670
|
+
* .addQueryBuilder(queryBuilder(productMappings).match('name', 'shoe'), { index: 'products' })
|
|
1671
|
+
* .addQueryBuilder(queryBuilder(productMappings).match('name', 'shirt'), { index: 'products' })
|
|
1672
|
+
* .withParams({ max_concurrent_searches: 5, typed_keys: true })
|
|
1673
|
+
* .build();
|
|
1674
|
+
*/
|
|
1675
|
+
declare const msearch: <M extends Record<string, FieldTypeString>>(_schema: MappingsSchema<M>) => MSearchBuilder<M>;
|
|
1676
|
+
//#endregion
|
|
1677
|
+
//#region src/bulk.types.d.ts
|
|
1678
|
+
/**
|
|
1679
|
+
* Metadata for bulk index operation — re-exported from official @elastic/elasticsearch types
|
|
1680
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
|
|
1681
|
+
*/
|
|
1682
|
+
type BulkIndexMeta = BulkIndexOperation;
|
|
1683
|
+
/**
|
|
1684
|
+
* Metadata for bulk create operation — re-exported from official @elastic/elasticsearch types
|
|
1685
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
|
|
1686
|
+
*/
|
|
1687
|
+
type BulkCreateMeta = BulkCreateOperation;
|
|
1688
|
+
/**
|
|
1689
|
+
* Metadata for bulk update operation.
|
|
1690
|
+
* Combines official BulkUpdateOperation (header) with BulkUpdateAction (body) for ergonomic API.
|
|
1691
|
+
* The builder splits these into separate header and body when building the bulk request.
|
|
1692
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
|
|
1693
|
+
*/
|
|
1694
|
+
type BulkUpdateMeta<T> = BulkUpdateOperation & BulkUpdateAction<T, Partial<T>>;
|
|
1695
|
+
/**
|
|
1696
|
+
* Metadata for bulk delete operation — re-exported from official @elastic/elasticsearch types
|
|
1697
|
+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
|
|
1698
|
+
*/
|
|
1699
|
+
type BulkDeleteMeta = BulkDeleteOperation;
|
|
1700
|
+
/**
|
|
1701
|
+
* Bulk operations builder interface
|
|
1702
|
+
*/
|
|
1703
|
+
type BulkBuilder<T> = {
|
|
1704
|
+
/** Index a document (create or replace) */index: (doc: T, meta?: BulkIndexMeta) => BulkBuilder<T>; /** Create a new document (fails if already exists) */
|
|
1705
|
+
create: (doc: T, meta?: BulkCreateMeta) => BulkBuilder<T>; /** Update an existing document */
|
|
1706
|
+
update: (meta: BulkUpdateMeta<T>) => BulkBuilder<T>; /** Delete a document */
|
|
1707
|
+
delete: (meta: BulkDeleteMeta) => BulkBuilder<T>; /** Build as NDJSON string format for Elasticsearch */
|
|
1708
|
+
build: () => string; /** Build as array of operation headers and document bodies. Alternating operation/document pairs (except `delete` which is header-only). */
|
|
1709
|
+
buildArray: () => Array<BulkOperationContainer$1 | T | Partial<T> | BulkUpdateAction<T, Partial<T>>>;
|
|
1710
|
+
};
|
|
1711
|
+
//#endregion
|
|
1712
|
+
//#region src/bulk.builder.d.ts
|
|
1713
|
+
/**
|
|
1714
|
+
* Create a new bulk operations builder.
|
|
1715
|
+
* `.build()` returns an NDJSON string (newline-delimited JSON) ready to POST to `/_bulk`.
|
|
1716
|
+
* `.buildArray()` returns the raw operation objects if you need to inspect or transform them.
|
|
1717
|
+
* @example
|
|
1718
|
+
* const ndjson = bulk(productMappings)
|
|
1719
|
+
* .index({ id: '1', name: 'Product 1' }, { _index: 'products', _id: '1' })
|
|
1720
|
+
* .create({ id: '2', name: 'Product 2' }, { _index: 'products', _id: '2' })
|
|
1721
|
+
* .update({ _index: 'products', _id: '3', doc: { name: 'Updated' } })
|
|
1722
|
+
* .delete({ _index: 'products', _id: '4' })
|
|
1723
|
+
* .build(); // POST to /_bulk with Content-Type: application/x-ndjson
|
|
1724
|
+
*/
|
|
1725
|
+
declare const bulk: <M extends Record<string, FieldTypeString>>(_schema: MappingsSchema<M>) => BulkBuilder<{
|
|
1726
|
+
[x: string]: unknown;
|
|
1727
|
+
}>;
|
|
1728
|
+
//#endregion
|
|
1729
|
+
//#region src/index-management.builder.d.ts
|
|
1730
|
+
/**
|
|
1731
|
+
* Create a new index builder for Elasticsearch index configuration.
|
|
1732
|
+
*
|
|
1733
|
+
* Typical lifecycle:
|
|
1734
|
+
* 1. **Create index:** `indexBuilder().mappings(schema).settings(productionSearchSettings()).build()`
|
|
1735
|
+
* 2. **Bulk ingest:** Apply `fastIngestSettings()` via ES `_settings` API → bulk index →
|
|
1736
|
+
* apply `productionSearchSettings()` → `POST /index/_refresh`
|
|
1737
|
+
* 3. **Normal operations:** Query, update individual docs via `_update` API
|
|
1738
|
+
* 4. **Migration with mapping changes:** Create new index with new mappings → `POST _reindex`
|
|
1739
|
+
* from old → atomically swap alias via `POST _aliases` → delete old index
|
|
1740
|
+
*
|
|
1741
|
+
* After bulk loading, remember to refresh the index with `POST /index/_refresh`
|
|
1742
|
+
* to make all documents searchable.
|
|
1743
|
+
*
|
|
1744
|
+
* @example
|
|
1745
|
+
* const indexConfig = indexBuilder()
|
|
1746
|
+
* .mappings(productMappings)
|
|
1747
|
+
* .settings(productionSearchSettings())
|
|
1748
|
+
* .alias('products')
|
|
1749
|
+
* .build();
|
|
1750
|
+
*/
|
|
1751
|
+
declare const indexBuilder: () => IndexBuilder;
|
|
1752
|
+
//#endregion
|
|
1753
|
+
//#region src/suggester.builder.d.ts
|
|
1754
|
+
/**
|
|
1755
|
+
* Factory function to create a new suggester builder
|
|
1756
|
+
* @example
|
|
1757
|
+
* ```typescript
|
|
1758
|
+
* const suggestions = suggest(productMappings)
|
|
1759
|
+
* .term('name-suggestions', 'laptop', { field: 'name', size: 5 })
|
|
1760
|
+
* .build();
|
|
1761
|
+
* ```
|
|
1762
|
+
*/
|
|
1763
|
+
declare const suggest: <M extends Record<string, FieldTypeString>>(_schema: MappingsSchema<M>) => SuggesterBuilder<M>;
|
|
1764
|
+
//#endregion
|
|
1765
|
+
//#region src/settings.presets.d.ts
|
|
1766
|
+
/**
|
|
1767
|
+
* Balanced production settings for search workloads.
|
|
1768
|
+
*
|
|
1769
|
+
* Defaults:
|
|
1770
|
+
* - `number_of_replicas: 1` — one replica for redundancy
|
|
1771
|
+
* - `refresh_interval: '5s'` — near-real-time search without excessive refresh overhead
|
|
1772
|
+
*
|
|
1773
|
+
* @param overrides - Override or extend any setting. Applied after defaults.
|
|
1774
|
+
*
|
|
1775
|
+
* @example
|
|
1776
|
+
* const index = indexBuilder()
|
|
1777
|
+
* .mappings(schema)
|
|
1778
|
+
* .settings(productionSearchSettings())
|
|
1779
|
+
* .build();
|
|
1780
|
+
*
|
|
1781
|
+
* @example
|
|
1782
|
+
* // With best_compression for disk savings
|
|
1783
|
+
* productionSearchSettings({ codec: 'best_compression' })
|
|
1784
|
+
*
|
|
1785
|
+
* @example
|
|
1786
|
+
* // Restore production settings after bulk ingest
|
|
1787
|
+
* await client.indices.putSettings({
|
|
1788
|
+
* index: 'my-index',
|
|
1789
|
+
* body: productionSearchSettings(),
|
|
1790
|
+
* });
|
|
1791
|
+
* await client.indices.refresh({ index: 'my-index' });
|
|
1792
|
+
*/
|
|
1793
|
+
declare const productionSearchSettings: (overrides?: Partial<IndicesIndexSettings>) => IndicesIndexSettings;
|
|
1794
|
+
/**
|
|
1795
|
+
* Per-field sort configuration for `indexSortSettings()`.
|
|
1796
|
+
* Either a bare direction, or a full spec with `mode`/`missing`.
|
|
1797
|
+
*/
|
|
1798
|
+
type IndexSortFieldSpec = 'asc' | 'desc' | {
|
|
1799
|
+
order: 'asc' | 'desc';
|
|
1800
|
+
mode?: IndicesSegmentSortMode;
|
|
1801
|
+
missing?: IndicesSegmentSortMissing;
|
|
1802
|
+
};
|
|
1803
|
+
/**
|
|
1804
|
+
* Generate index sort settings from a field→direction (or full spec) map.
|
|
1805
|
+
*
|
|
1806
|
+
* Index-time sorting improves compression (similar values stored together) and
|
|
1807
|
+
* enables early termination when query sort matches index sort. Combine with
|
|
1808
|
+
* `trackTotalHits(false)` for fastest sorted queries.
|
|
1809
|
+
*
|
|
1810
|
+
* The returned object lives at the top level of `IndicesIndexSettings` — spread it
|
|
1811
|
+
* directly into a settings object (do NOT wrap it under an `index` key, the
|
|
1812
|
+
* `@elastic/elasticsearch` client normalises that form).
|
|
1813
|
+
*
|
|
1814
|
+
* Pass a bare `'asc' | 'desc'` for simple cases; pass `{ order, mode?, missing? }`
|
|
1815
|
+
* when you need `mode` (`min`/`max`/`median`/`avg`) or `missing` (`_first`/`_last`).
|
|
1816
|
+
*
|
|
1817
|
+
* @param fields - Map of field names to sort direction or full spec.
|
|
1818
|
+
* @returns A `{ sort: IndicesIndexSegmentSort }` fragment to spread into your settings.
|
|
1819
|
+
*
|
|
1820
|
+
* @example
|
|
1821
|
+
* const index = indexBuilder()
|
|
1822
|
+
* .mappings(schema)
|
|
1823
|
+
* .settings({
|
|
1824
|
+
* ...productionSearchSettings(),
|
|
1825
|
+
* ...indexSortSettings({ timestamp: 'desc', status: 'asc' }),
|
|
1826
|
+
* })
|
|
1827
|
+
* .build();
|
|
1828
|
+
*
|
|
1829
|
+
* @example
|
|
1830
|
+
* indexSortSettings({
|
|
1831
|
+
* price: { order: 'asc', mode: 'min', missing: '_last' },
|
|
1832
|
+
* created_at: 'desc'
|
|
1833
|
+
* })
|
|
1834
|
+
*/
|
|
1835
|
+
declare const indexSortSettings: (fields: Record<string, IndexSortFieldSpec>) => {
|
|
1836
|
+
sort: IndicesIndexSegmentSort;
|
|
1837
|
+
};
|
|
1838
|
+
/**
|
|
1839
|
+
* Settings optimized for maximum indexing speed during bulk operations.
|
|
1840
|
+
*
|
|
1841
|
+
* Apply via the ES `_settings` API before starting bulk ingest, then revert
|
|
1842
|
+
* with `productionSearchSettings()` afterward. Do not use these as permanent
|
|
1843
|
+
* index settings — they trade durability and search availability for speed.
|
|
1844
|
+
*
|
|
1845
|
+
* Defaults:
|
|
1846
|
+
* - `refresh_interval: '-1'` — disables refresh (can improve reindex time by 70%+)
|
|
1847
|
+
* - `number_of_replicas: 0` — no replication overhead during ingest
|
|
1848
|
+
* - `translog.durability: 'async'` — async translog for faster writes
|
|
1849
|
+
* - `translog.sync_interval: '30s'` — less frequent translog sync
|
|
1850
|
+
*
|
|
1851
|
+
* @param overrides - Override or extend any setting. Applied after defaults.
|
|
1852
|
+
* `translog` overrides are deep-merged so individual translog keys can be
|
|
1853
|
+
* changed without clobbering the other defaults.
|
|
1854
|
+
*
|
|
1855
|
+
* @example
|
|
1856
|
+
* // Apply before bulk ingest via ES client
|
|
1857
|
+
* await client.indices.putSettings({
|
|
1858
|
+
* index: 'my-index',
|
|
1859
|
+
* body: fastIngestSettings(),
|
|
1860
|
+
* });
|
|
1861
|
+
*
|
|
1862
|
+
* @example
|
|
1863
|
+
* // With custom overrides
|
|
1864
|
+
* fastIngestSettings({ number_of_shards: 3 })
|
|
1865
|
+
*/
|
|
1866
|
+
declare const fastIngestSettings: (overrides?: Partial<IndicesIndexSettings>) => IndicesIndexSettings;
|
|
1867
|
+
//#endregion
|
|
1868
|
+
//#region src/index.d.ts
|
|
1869
|
+
declare const queryBuilder: <M extends Record<string, FieldTypeString>>(_schema: MappingsSchema<M>, includeQuery?: boolean) => QueryBuilder<M>;
|
|
1870
|
+
/**
|
|
1871
|
+
* Type inference helper for vanilla JavaScript.
|
|
1872
|
+
*
|
|
1873
|
+
* **Type-only — do not use the returned value at runtime.** This function always returns
|
|
1874
|
+
* `undefined`; its declared return type is a lie used to carry `Infer<typeof schema>` into
|
|
1875
|
+
* JSDoc `@type` annotations. Accessing properties on the return value (e.g. `inferType(s).name`)
|
|
1876
|
+
* will throw `TypeError`.
|
|
1877
|
+
*
|
|
1878
|
+
* @example
|
|
1879
|
+
* const schema = mappings({ name: text() });
|
|
1880
|
+
* const _Product = inferType(schema); // undefined at runtime; type-only
|
|
1881
|
+
*
|
|
1882
|
+
* /** @type {typeof _Product} *\/
|
|
1883
|
+
* const doc = { name: 'Laptop' };
|
|
1884
|
+
*
|
|
1885
|
+
* In TypeScript, prefer `type Product = Infer<typeof schema>` directly.
|
|
1886
|
+
*/
|
|
1887
|
+
declare const inferType: <M extends Record<string, FieldTypeString>, F extends Record<string, FieldMappingWithLiteralType>>(_schema: MappingsSchema<M, F>) => Infer<MappingsSchema<M, F>>;
|
|
1888
|
+
//#endregion
|
|
1889
|
+
export { type AnalysisAnalyzerConfig, type AnalysisCharFilterConfig, type AnalysisConfig, type AnalysisNormalizerConfig, type AnalysisTokenFilterConfig, type AnalysisTokenizerConfig, type BooleanFields, type BulkBuilder, type BulkOperationContainer, type ClauseBuilder, type CompletionFields, type CompletionSuggestContext, type CompletionSuggesterOptions, type DateFields, type DateNanosFieldOptions, type DenseVectorFields, type FieldMappingWithLiteralType, type FieldsOfType, type FunctionScoreOptions, type GeoPointFields, type GeoShapeFields, type HasChildOptions, type HasParentOptions, type IndexBuilder, type IndexSortFieldSpec, type Infer, type IntervalsOptions, type IpFields, type IpRangeFieldOptions, type JoinFieldOptions, type KeywordFields, type MSearchBuilder, type MSearchHeader, type MSearchRequestParams, type MappingsSchema, type NestedAggregationBuilder, type NestedEntryBuilder, type NestedFieldOptions, type NumericFields, type ObjectFieldOptions, type ParentIdOptions, type PhraseSuggestCollate, type PhraseSuggestDirectGenerator, type PhraseSuggestSmoothingModel, type PhraseSuggesterOptions, type QueryBuilder, type RankFeatureFields, type RootAggregationBuilder, type SpanNearOptions, type SpanNotOptions, type SpanQuery, type SparseVectorFields, type SuggesterBuilder, type TermSuggesterOptions, type TextFields, type TokenCountFieldOptions, type TypedNestedFieldMapping, type TypedObjectFieldMapping, type UnsignedLongFieldOptions, type VectorFields, aggregations, alias, binary, boolean, bulk, byte, completion, constantKeyword, date, dateNanos, dateRange, denseVector, double, doubleRange, fastIngestSettings, flattened, float, floatRange, geoPoint, geoShape, halfFloat, indexBuilder, indexSortSettings, inferType, integer, integerRange, ip, ipRange, join, keyword, long, longRange, mappings, matchOnlyText, msearch, murmur3Hash, nested, object, percolator, productionSearchSettings, quantizedDenseVector, queryBuilder, rankFeature, rankFeatures, scaledFloat, searchAsYouType, semanticText, short, sparseVector, suggest, text, tokenCount, unsignedLong, wildcardField };
|
|
1890
|
+
//# sourceMappingURL=index.d.cts.map
|