elasticlink 1.0.0-beta.1 → 1.0.0

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.
Files changed (64) hide show
  1. package/README.md +74 -31
  2. package/dist/index.cjs +1528 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +1890 -0
  5. package/dist/index.d.cts.map +1 -0
  6. package/dist/index.d.ts +1889 -20
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1474 -18
  9. package/dist/index.js.map +1 -0
  10. package/package.json +27 -21
  11. package/dist/aggregation.builder.d.ts +0 -6
  12. package/dist/aggregation.builder.d.ts.map +0 -1
  13. package/dist/aggregation.builder.js +0 -81
  14. package/dist/aggregation.types.d.ts +0 -258
  15. package/dist/aggregation.types.d.ts.map +0 -1
  16. package/dist/aggregation.types.js +0 -6
  17. package/dist/bulk.builder.d.ts +0 -29
  18. package/dist/bulk.builder.d.ts.map +0 -1
  19. package/dist/bulk.builder.js +0 -51
  20. package/dist/bulk.types.d.ts +0 -47
  21. package/dist/bulk.types.d.ts.map +0 -1
  22. package/dist/bulk.types.js +0 -6
  23. package/dist/field.helpers.d.ts +0 -241
  24. package/dist/field.helpers.d.ts.map +0 -1
  25. package/dist/field.helpers.js +0 -333
  26. package/dist/field.types.d.ts +0 -348
  27. package/dist/field.types.d.ts.map +0 -1
  28. package/dist/field.types.js +0 -6
  29. package/dist/index-management.builder.d.ts +0 -38
  30. package/dist/index-management.builder.d.ts.map +0 -1
  31. package/dist/index-management.builder.js +0 -69
  32. package/dist/index-management.types.d.ts +0 -136
  33. package/dist/index-management.types.d.ts.map +0 -1
  34. package/dist/index-management.types.js +0 -6
  35. package/dist/mapping.builder.d.ts +0 -53
  36. package/dist/mapping.builder.d.ts.map +0 -1
  37. package/dist/mapping.builder.js +0 -39
  38. package/dist/mapping.types.d.ts +0 -200
  39. package/dist/mapping.types.d.ts.map +0 -1
  40. package/dist/mapping.types.js +0 -6
  41. package/dist/multi-search.builder.d.ts +0 -23
  42. package/dist/multi-search.builder.d.ts.map +0 -1
  43. package/dist/multi-search.builder.js +0 -48
  44. package/dist/multi-search.types.d.ts +0 -50
  45. package/dist/multi-search.types.d.ts.map +0 -1
  46. package/dist/multi-search.types.js +0 -6
  47. package/dist/query.builder.d.ts +0 -4
  48. package/dist/query.builder.d.ts.map +0 -1
  49. package/dist/query.builder.js +0 -329
  50. package/dist/query.types.d.ts +0 -468
  51. package/dist/query.types.d.ts.map +0 -1
  52. package/dist/query.types.js +0 -7
  53. package/dist/settings.presets.d.ts +0 -117
  54. package/dist/settings.presets.d.ts.map +0 -1
  55. package/dist/settings.presets.js +0 -137
  56. package/dist/suggester.builder.d.ts +0 -23
  57. package/dist/suggester.builder.d.ts.map +0 -1
  58. package/dist/suggester.builder.js +0 -51
  59. package/dist/suggester.types.d.ts +0 -90
  60. package/dist/suggester.types.d.ts.map +0 -1
  61. package/dist/suggester.types.js +0 -6
  62. package/dist/vector.types.d.ts +0 -17
  63. package/dist/vector.types.d.ts.map +0 -1
  64. package/dist/vector.types.js +0 -6
@@ -1,241 +0,0 @@
1
- /**
2
- * Field type helper functions for ergonomic index mapping definitions.
3
- * Each helper returns a narrowly-typed mapping with a literal `type` field,
4
- * enabling compile-time field-type inference in the query builder.
5
- *
6
- * @example
7
- * import { text, keyword, denseVector, mappings } from 'elasticlink';
8
- *
9
- * const productMappings = mappings({
10
- * name: text({ analyzer: 'standard' }),
11
- * price: float(),
12
- * category: keyword(),
13
- * embedding: denseVector({ dims: 384 }),
14
- * });
15
- */
16
- import type { TextFieldOptions, KeywordFieldOptions, NumericFieldOptions, UnsignedLongFieldOptions, ScaledFloatFieldOptions, DateFieldOptions, DateNanosFieldOptions, IpRangeFieldOptions, NestedFieldOptions, BooleanFieldOptions, DenseVectorFieldOptions, RankFeatureFieldOptions, RankFeaturesFieldOptions, SemanticTextFieldOptions, ObjectFieldOptions, CompletionFieldOptions, GeoPointFieldOptions, GeoShapeFieldOptions, AliasFieldOptions, IpFieldOptions, RangeFieldOptions, MatchOnlyTextFieldOptions, SearchAsYouTypeFieldOptions, ConstantKeywordFieldOptions, WildcardFieldOptions, FlattenedFieldOptions, TokenCountFieldOptions, JoinFieldOptions, FieldMappingWithLiteralType, TextFieldMapping, KeywordFieldMapping, LongFieldMapping, IntegerFieldMapping, ShortFieldMapping, ByteFieldMapping, DoubleFieldMapping, FloatFieldMapping, HalfFloatFieldMapping, ScaledFloatFieldMapping, DateFieldMapping, DateNanosFieldMapping, IpRangeFieldMapping, BooleanFieldMapping, BinaryFieldMapping, IpFieldMapping, DenseVectorFieldMapping, SparseVectorFieldMapping, RankFeatureFieldMapping, RankFeaturesFieldMapping, SemanticTextFieldMapping, UnsignedLongFieldMapping, GeoPointFieldMapping, GeoShapeFieldMapping, CompletionFieldMapping, TypedNestedFieldMapping, TypedObjectFieldMapping, AliasFieldMapping, PercolatorFieldMapping, IntegerRangeFieldMapping, FloatRangeFieldMapping, LongRangeFieldMapping, DoubleRangeFieldMapping, DateRangeFieldMapping, MatchOnlyTextFieldMapping, SearchAsYouTypeFieldMapping, ConstantKeywordFieldMapping, WildcardFieldMapping, FlattenedFieldMapping, TokenCountFieldMapping, Murmur3FieldMapping, JoinFieldMapping } from './field.types.js';
17
- export declare const text: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: TextFieldOptions<MF>) => TextFieldMapping & Readonly<{
18
- _multiFields: MF;
19
- }>;
20
- export declare const keyword: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: KeywordFieldOptions<MF>) => KeywordFieldMapping & Readonly<{
21
- _multiFields: MF;
22
- }>;
23
- export declare const long: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => LongFieldMapping & Readonly<{
24
- _multiFields: MF;
25
- }>;
26
- export declare const integer: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => IntegerFieldMapping & Readonly<{
27
- _multiFields: MF;
28
- }>;
29
- export declare const short: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => ShortFieldMapping & Readonly<{
30
- _multiFields: MF;
31
- }>;
32
- export declare const byte: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => ByteFieldMapping & Readonly<{
33
- _multiFields: MF;
34
- }>;
35
- export declare const double: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => DoubleFieldMapping & Readonly<{
36
- _multiFields: MF;
37
- }>;
38
- export declare const float: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => FloatFieldMapping & Readonly<{
39
- _multiFields: MF;
40
- }>;
41
- export declare const halfFloat: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: NumericFieldOptions<MF>) => HalfFloatFieldMapping & Readonly<{
42
- _multiFields: MF;
43
- }>;
44
- export declare const scaledFloat: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: ScaledFloatFieldOptions<MF>) => ScaledFloatFieldMapping & Readonly<{
45
- _multiFields: MF;
46
- }>;
47
- export declare const date: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: DateFieldOptions<MF>) => DateFieldMapping & Readonly<{
48
- _multiFields: MF;
49
- }>;
50
- /**
51
- * Date field stored with nanosecond precision. Same API as `date()` but supports sub-millisecond timestamps.
52
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/date_nanos.html
53
- */
54
- export declare const dateNanos: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: DateNanosFieldOptions<MF>) => DateNanosFieldMapping & Readonly<{
55
- _multiFields: MF;
56
- }>;
57
- export declare const boolean: (options?: BooleanFieldOptions) => BooleanFieldMapping;
58
- export declare const binary: () => BinaryFieldMapping;
59
- export declare const ip: (options?: IpFieldOptions) => IpFieldMapping;
60
- export declare const denseVector: (options?: DenseVectorFieldOptions) => DenseVectorFieldMapping;
61
- /**
62
- * Quantized dense vector field — wraps `denseVector()` with `int8_hnsw` index type.
63
- *
64
- * Quantizes float32 vectors to int8 at index time, saving ~75% memory.
65
- * Recommended for vectors with dims >= 384. Original float vectors are retained
66
- * in the index, enabling a two-phase search pattern:
67
- *
68
- * 1. Fast approximate search using quantized int8 vectors
69
- * 2. Precise rescore of top-k results using retained float vectors
70
- *
71
- * @example
72
- * // Index mapping
73
- * const schema = mappings({
74
- * title: text(),
75
- * embedding: quantizedDenseVector({ dims: 768, similarity: 'cosine' }),
76
- * }, {
77
- * _source: { excludes: ['embedding'] },
78
- * });
79
- *
80
- * // Two-phase search: fast kNN + precise rescore
81
- * const result = queryBuilder(schema)
82
- * .knn('embedding', queryVector, { k: 100, num_candidates: 200 })
83
- * .rescore(
84
- * (q) => q.scriptScore(
85
- * (inner) => inner.matchAll(),
86
- * { source: "cosineSimilarity(params.v, 'embedding') + 1.0", params: { v: queryVector } }
87
- * ),
88
- * 100
89
- * )
90
- * .build();
91
- */
92
- export declare const quantizedDenseVector: (options?: DenseVectorFieldOptions) => DenseVectorFieldMapping;
93
- /**
94
- * Sparse vector field — stores token-weight pairs for sparse retrieval (e.g. ELSER/BM25-style models).
95
- * Complement to `denseVector()`. Query with the `sparse_vector` query.
96
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sparse-vector.html
97
- */
98
- export declare const sparseVector: () => SparseVectorFieldMapping;
99
- /**
100
- * Rank feature field — a single numeric feature used by the `rank_feature` query to boost relevance.
101
- * Use when each document has one named signal (e.g. `pagerank`, `popularity_score`).
102
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rank-feature.html
103
- */
104
- export declare const rankFeature: (options?: RankFeatureFieldOptions) => RankFeatureFieldMapping;
105
- /**
106
- * Rank features field — a sparse map of numeric features used by the `rank_feature` query.
107
- * Use when each document has many named signals (e.g. topic scores).
108
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rank-features.html
109
- */
110
- export declare const rankFeatures: (options?: RankFeaturesFieldOptions) => RankFeaturesFieldMapping;
111
- /**
112
- * Semantic text field (ES 9.x) — ML-powered text field for semantic and hybrid search.
113
- * Automatically generates and stores embeddings at index time using the configured inference endpoint.
114
- *
115
- * @example
116
- * const schema = mappings({
117
- * title: text(),
118
- * body: semanticText({ inference_id: 'my-elser-endpoint' }),
119
- * });
120
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-text.html
121
- */
122
- export declare const semanticText: (options?: SemanticTextFieldOptions) => SemanticTextFieldMapping;
123
- /**
124
- * Unsigned long field (ES 9.0+) — stores unsigned 64-bit integer values (0 to 2^64-1).
125
- * Use when values exceed the `long` range.
126
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html
127
- */
128
- export declare const unsignedLong: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: UnsignedLongFieldOptions<MF>) => UnsignedLongFieldMapping & Readonly<{
129
- _multiFields: MF;
130
- }>;
131
- export declare const geoPoint: (options?: GeoPointFieldOptions) => GeoPointFieldMapping;
132
- export declare const geoShape: (options?: GeoShapeFieldOptions) => GeoShapeFieldMapping;
133
- export declare const completion: (options?: CompletionFieldOptions) => CompletionFieldMapping;
134
- /**
135
- * Object field — for JSON-like structured documents where sub-fields are queried with dot-notation.
136
- *
137
- * The most common way to model structured data (e.g. `{ address: { city, zip } }`).
138
- * Sub-fields are indexed inline within the parent document — no special query wrapper needed.
139
- * Query sub-fields directly using dot-notation: `.term('address.city', 'NYC')`.
140
- *
141
- * Use `nested()` instead when you have **arrays of objects** and need cross-field queries
142
- * within each element to be accurate (e.g. tags with both a label and weight).
143
- *
144
- * @example
145
- * const m = mappings({
146
- * address: object({
147
- * street: text(),
148
- * city: keyword(),
149
- * zip: keyword(),
150
- * }),
151
- * });
152
- * queryBuilder(m).term('address.city', 'NYC').build();
153
- */
154
- export declare function object<F extends Record<string, FieldMappingWithLiteralType>>(fields: F, options?: ObjectFieldOptions): TypedObjectFieldMapping<F>;
155
- /**
156
- * Nested field — for **arrays of objects** where cross-field queries within each element must be accurate.
157
- *
158
- * Each nested object is stored as a separate hidden Elasticsearch document, preserving the
159
- * relationship between sub-fields within each element. Without `nested`, Elasticsearch flattens
160
- * array sub-fields and loses which values belong to the same element.
161
- *
162
- * Queries on nested fields **must** use the `.nested()` query builder method — direct dot-notation
163
- * queries will not find nested documents.
164
- *
165
- * Use `object()` instead for single structured objects (addresses, names, etc.) — it is simpler,
166
- * more efficient, and does not require a query wrapper.
167
- *
168
- * @example
169
- * const m = mappings({
170
- * tags: nested({
171
- * label: keyword(),
172
- * weight: float(),
173
- * }),
174
- * });
175
- * queryBuilder(m).nested('tags', q => q.term('label', 'sale')).build();
176
- */
177
- export declare function nested<F extends Record<string, FieldMappingWithLiteralType>>(fields: F, options?: NestedFieldOptions): TypedNestedFieldMapping<F>;
178
- export declare const alias: (options: AliasFieldOptions) => AliasFieldMapping;
179
- export declare const percolator: () => PercolatorFieldMapping;
180
- export declare const integerRange: (options?: RangeFieldOptions) => IntegerRangeFieldMapping;
181
- export declare const floatRange: (options?: RangeFieldOptions) => FloatRangeFieldMapping;
182
- export declare const longRange: (options?: RangeFieldOptions) => LongRangeFieldMapping;
183
- export declare const doubleRange: (options?: RangeFieldOptions) => DoubleRangeFieldMapping;
184
- export declare const dateRange: (options?: RangeFieldOptions) => DateRangeFieldMapping;
185
- /**
186
- * IP range field — stores a range of IPv4/IPv6 addresses.
187
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/range.html
188
- */
189
- export declare const ipRange: (options?: IpRangeFieldOptions) => IpRangeFieldMapping;
190
- /**
191
- * No-score text field — faster and uses less disk than `text()`.
192
- * Use when you only need filter/match but not relevance scoring (e.g., logs, simple field matches).
193
- */
194
- export declare const matchOnlyText: <MF extends Record<string, FieldMappingWithLiteralType>>(options?: MatchOnlyTextFieldOptions<MF>) => MatchOnlyTextFieldMapping & Readonly<{
195
- _multiFields: MF;
196
- }>;
197
- /**
198
- * Autocomplete / typeahead field. Creates sub-fields for edge n-gram matching
199
- * out of the box. Query with `multi_match` targeting the generated sub-fields.
200
- */
201
- export declare const searchAsYouType: (options?: SearchAsYouTypeFieldOptions) => SearchAsYouTypeFieldMapping;
202
- /**
203
- * Field where every document has the same value. Useful for multi-index queries
204
- * to identify the index type (e.g., `constantKeyword({ value: 'product' })`).
205
- */
206
- export declare const constantKeyword: (options?: ConstantKeywordFieldOptions) => ConstantKeywordFieldMapping;
207
- /**
208
- * Optimized for grep-like wildcard/regexp queries on high-cardinality or large fields.
209
- * Use instead of `keyword()` when leading wildcards (`*foo`) are needed.
210
- */
211
- export declare const wildcardField: (options?: WildcardFieldOptions) => WildcardFieldMapping;
212
- /**
213
- * Flattens complex/dynamic objects into a single field. Faster than `nested()`,
214
- * but only supports keyword-level queries on inner values.
215
- */
216
- export declare const flattened: (options?: FlattenedFieldOptions) => FlattenedFieldMapping;
217
- /**
218
- * Token count field — stores the number of tokens produced by an analyzer.
219
- * Useful for enforcing minimum/maximum field lengths via queries or aggregations.
220
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/token-count.html
221
- */
222
- export declare const tokenCount: (options?: TokenCountFieldOptions) => TokenCountFieldMapping;
223
- /**
224
- * Murmur3 hash field — computes and stores a murmur3 hash of field values at index time.
225
- * Requires the `mapper-murmur3` plugin.
226
- * @see https://www.elastic.co/guide/en/elasticsearch/plugins/current/mapper-murmur3.html
227
- */
228
- export declare const murmur3Hash: () => Murmur3FieldMapping;
229
- /**
230
- * Join field — defines parent/child relationships within a single index.
231
- * `relations` is required: maps parent names to one or more child names.
232
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html
233
- *
234
- * @example
235
- * const m = mappings({
236
- * title: text(),
237
- * relation: join({ relations: { question: 'answer' } }),
238
- * });
239
- */
240
- export declare const join: (options: JoinFieldOptions) => JoinFieldMapping;
241
- //# sourceMappingURL=field.helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"field.helpers.d.ts","sourceRoot":"","sources":["../src/field.helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV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O,mBAA4C,CAAC;AAE5E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,GAAI,SAAS,gBAAgB,KAAG,gBAG/C,CAAC"}
@@ -1,333 +0,0 @@
1
- /**
2
- * Field type helper functions for ergonomic index mapping definitions.
3
- * Each helper returns a narrowly-typed mapping with a literal `type` field,
4
- * enabling compile-time field-type inference in the query builder.
5
- *
6
- * @example
7
- * import { text, keyword, denseVector, mappings } from 'elasticlink';
8
- *
9
- * const productMappings = mappings({
10
- * name: text({ analyzer: 'standard' }),
11
- * price: float(),
12
- * category: keyword(),
13
- * embedding: denseVector({ dims: 384 }),
14
- * });
15
- */
16
- // Text & keyword
17
- export const text = (options) =>
18
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
- ({ type: 'text', ...options });
20
- export const keyword = (options) =>
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- ({ type: 'keyword', ...options });
23
- // Numeric
24
- export const long = (options
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- ) => ({ type: 'long', ...options });
27
- export const integer = (options
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
- ) => ({ type: 'integer', ...options });
30
- export const short = (options
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- ) => ({ type: 'short', ...options });
33
- export const byte = (options
34
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
- ) => ({ type: 'byte', ...options });
36
- export const double = (options
37
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
- ) => ({ type: 'double', ...options });
39
- export const float = (options
40
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- ) => ({ type: 'float', ...options });
42
- export const halfFloat = (options
43
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- ) => ({ type: 'half_float', ...options });
45
- export const scaledFloat = (options
46
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
- ) => ({ type: 'scaled_float', ...options });
48
- // Date & boolean
49
- export const date = (options
50
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
- ) => ({ type: 'date', ...options });
52
- /**
53
- * Date field stored with nanosecond precision. Same API as `date()` but supports sub-millisecond timestamps.
54
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/date_nanos.html
55
- */
56
- export const dateNanos = (options
57
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
- ) => ({ type: 'date_nanos', ...options });
59
- export const boolean = (options) => ({
60
- type: 'boolean',
61
- ...options
62
- });
63
- // Binary
64
- // eslint-disable-next-line functional/functional-parameters
65
- export const binary = () => ({ type: 'binary' });
66
- // IP
67
- export const ip = (options) => ({
68
- type: 'ip',
69
- ...options
70
- });
71
- // Vector
72
- export const denseVector = (options) => ({
73
- type: 'dense_vector',
74
- ...options
75
- });
76
- /**
77
- * Quantized dense vector field — wraps `denseVector()` with `int8_hnsw` index type.
78
- *
79
- * Quantizes float32 vectors to int8 at index time, saving ~75% memory.
80
- * Recommended for vectors with dims >= 384. Original float vectors are retained
81
- * in the index, enabling a two-phase search pattern:
82
- *
83
- * 1. Fast approximate search using quantized int8 vectors
84
- * 2. Precise rescore of top-k results using retained float vectors
85
- *
86
- * @example
87
- * // Index mapping
88
- * const schema = mappings({
89
- * title: text(),
90
- * embedding: quantizedDenseVector({ dims: 768, similarity: 'cosine' }),
91
- * }, {
92
- * _source: { excludes: ['embedding'] },
93
- * });
94
- *
95
- * // Two-phase search: fast kNN + precise rescore
96
- * const result = queryBuilder(schema)
97
- * .knn('embedding', queryVector, { k: 100, num_candidates: 200 })
98
- * .rescore(
99
- * (q) => q.scriptScore(
100
- * (inner) => inner.matchAll(),
101
- * { source: "cosineSimilarity(params.v, 'embedding') + 1.0", params: { v: queryVector } }
102
- * ),
103
- * 100
104
- * )
105
- * .build();
106
- */
107
- export const quantizedDenseVector = (options) => ({
108
- type: 'dense_vector',
109
- ...options,
110
- index_options: { type: 'int8_hnsw', ...options?.index_options }
111
- });
112
- /**
113
- * Sparse vector field — stores token-weight pairs for sparse retrieval (e.g. ELSER/BM25-style models).
114
- * Complement to `denseVector()`. Query with the `sparse_vector` query.
115
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sparse-vector.html
116
- */
117
- // eslint-disable-next-line functional/functional-parameters
118
- export const sparseVector = () => ({ type: 'sparse_vector' });
119
- /**
120
- * Rank feature field — a single numeric feature used by the `rank_feature` query to boost relevance.
121
- * Use when each document has one named signal (e.g. `pagerank`, `popularity_score`).
122
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rank-feature.html
123
- */
124
- export const rankFeature = (options) => ({
125
- type: 'rank_feature',
126
- ...options
127
- });
128
- /**
129
- * Rank features field — a sparse map of numeric features used by the `rank_feature` query.
130
- * Use when each document has many named signals (e.g. topic scores).
131
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rank-features.html
132
- */
133
- export const rankFeatures = (options) => ({
134
- type: 'rank_features',
135
- ...options
136
- });
137
- /**
138
- * Semantic text field (ES 9.x) — ML-powered text field for semantic and hybrid search.
139
- * Automatically generates and stores embeddings at index time using the configured inference endpoint.
140
- *
141
- * @example
142
- * const schema = mappings({
143
- * title: text(),
144
- * body: semanticText({ inference_id: 'my-elser-endpoint' }),
145
- * });
146
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-text.html
147
- */
148
- export const semanticText = (options) => ({
149
- type: 'semantic_text',
150
- ...options
151
- });
152
- /**
153
- * Unsigned long field (ES 9.0+) — stores unsigned 64-bit integer values (0 to 2^64-1).
154
- * Use when values exceed the `long` range.
155
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html
156
- */
157
- export const unsignedLong = (options
158
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
- ) => ({ type: 'unsigned_long', ...options });
160
- // Geo
161
- export const geoPoint = (options) => ({
162
- type: 'geo_point',
163
- ...options
164
- });
165
- export const geoShape = (options) => ({
166
- type: 'geo_shape',
167
- ...options
168
- });
169
- // Completion
170
- export const completion = (options) => ({
171
- type: 'completion',
172
- ...options
173
- });
174
- // Structured
175
- /**
176
- * Object field — for JSON-like structured documents where sub-fields are queried with dot-notation.
177
- *
178
- * The most common way to model structured data (e.g. `{ address: { city, zip } }`).
179
- * Sub-fields are indexed inline within the parent document — no special query wrapper needed.
180
- * Query sub-fields directly using dot-notation: `.term('address.city', 'NYC')`.
181
- *
182
- * Use `nested()` instead when you have **arrays of objects** and need cross-field queries
183
- * within each element to be accurate (e.g. tags with both a label and weight).
184
- *
185
- * @example
186
- * const m = mappings({
187
- * address: object({
188
- * street: text(),
189
- * city: keyword(),
190
- * zip: keyword(),
191
- * }),
192
- * });
193
- * queryBuilder(m).term('address.city', 'NYC').build();
194
- */
195
- export function object(fields, options) {
196
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
197
- return { type: 'object', ...(options ?? {}), properties: fields };
198
- }
199
- /**
200
- * Nested field — for **arrays of objects** where cross-field queries within each element must be accurate.
201
- *
202
- * Each nested object is stored as a separate hidden Elasticsearch document, preserving the
203
- * relationship between sub-fields within each element. Without `nested`, Elasticsearch flattens
204
- * array sub-fields and loses which values belong to the same element.
205
- *
206
- * Queries on nested fields **must** use the `.nested()` query builder method — direct dot-notation
207
- * queries will not find nested documents.
208
- *
209
- * Use `object()` instead for single structured objects (addresses, names, etc.) — it is simpler,
210
- * more efficient, and does not require a query wrapper.
211
- *
212
- * @example
213
- * const m = mappings({
214
- * tags: nested({
215
- * label: keyword(),
216
- * weight: float(),
217
- * }),
218
- * });
219
- * queryBuilder(m).nested('tags', q => q.term('label', 'sale')).build();
220
- */
221
- export function nested(fields, options) {
222
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
223
- return { type: 'nested', ...(options ?? {}), properties: fields };
224
- }
225
- // Alias
226
- export const alias = (options) => ({
227
- type: 'alias',
228
- ...options
229
- });
230
- // Percolator
231
- // eslint-disable-next-line functional/functional-parameters
232
- export const percolator = () => ({
233
- type: 'percolator'
234
- });
235
- // Range types
236
- export const integerRange = (options) => ({
237
- type: 'integer_range',
238
- ...options
239
- });
240
- export const floatRange = (options) => ({
241
- type: 'float_range',
242
- ...options
243
- });
244
- export const longRange = (options) => ({
245
- type: 'long_range',
246
- ...options
247
- });
248
- export const doubleRange = (options) => ({
249
- type: 'double_range',
250
- ...options
251
- });
252
- export const dateRange = (options) => ({
253
- type: 'date_range',
254
- ...options
255
- });
256
- /**
257
- * IP range field — stores a range of IPv4/IPv6 addresses.
258
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/range.html
259
- */
260
- export const ipRange = (options) => ({
261
- type: 'ip_range',
262
- ...options
263
- });
264
- /**
265
- * No-score text field — faster and uses less disk than `text()`.
266
- * Use when you only need filter/match but not relevance scoring (e.g., logs, simple field matches).
267
- */
268
- export const matchOnlyText = (options
269
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
270
- ) => ({ type: 'match_only_text', ...options });
271
- /**
272
- * Autocomplete / typeahead field. Creates sub-fields for edge n-gram matching
273
- * out of the box. Query with `multi_match` targeting the generated sub-fields.
274
- */
275
- export const searchAsYouType = (options) => ({
276
- type: 'search_as_you_type',
277
- ...options
278
- });
279
- /**
280
- * Field where every document has the same value. Useful for multi-index queries
281
- * to identify the index type (e.g., `constantKeyword({ value: 'product' })`).
282
- */
283
- export const constantKeyword = (options) => ({
284
- type: 'constant_keyword',
285
- ...options
286
- });
287
- /**
288
- * Optimized for grep-like wildcard/regexp queries on high-cardinality or large fields.
289
- * Use instead of `keyword()` when leading wildcards (`*foo`) are needed.
290
- */
291
- export const wildcardField = (options) => ({
292
- type: 'wildcard',
293
- ...options
294
- });
295
- /**
296
- * Flattens complex/dynamic objects into a single field. Faster than `nested()`,
297
- * but only supports keyword-level queries on inner values.
298
- */
299
- export const flattened = (options) => ({
300
- type: 'flattened',
301
- ...options
302
- });
303
- /**
304
- * Token count field — stores the number of tokens produced by an analyzer.
305
- * Useful for enforcing minimum/maximum field lengths via queries or aggregations.
306
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/token-count.html
307
- */
308
- export const tokenCount = (options) => ({
309
- type: 'token_count',
310
- ...options
311
- });
312
- /**
313
- * Murmur3 hash field — computes and stores a murmur3 hash of field values at index time.
314
- * Requires the `mapper-murmur3` plugin.
315
- * @see https://www.elastic.co/guide/en/elasticsearch/plugins/current/mapper-murmur3.html
316
- */
317
- // eslint-disable-next-line functional/functional-parameters
318
- export const murmur3Hash = () => ({ type: 'murmur3' });
319
- /**
320
- * Join field — defines parent/child relationships within a single index.
321
- * `relations` is required: maps parent names to one or more child names.
322
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html
323
- *
324
- * @example
325
- * const m = mappings({
326
- * title: text(),
327
- * relation: join({ relations: { question: 'answer' } }),
328
- * });
329
- */
330
- export const join = (options) => ({
331
- type: 'join',
332
- ...options
333
- });