elasticlink 0.2.2-beta → 0.3.0-beta
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 +162 -163
- package/dist/aggregation.builder.d.ts +4 -2
- package/dist/aggregation.builder.d.ts.map +1 -1
- package/dist/aggregation.builder.js +1 -1
- package/dist/aggregation.types.d.ts +15 -14
- package/dist/aggregation.types.d.ts.map +1 -1
- package/dist/bulk.builder.d.ts +115 -1
- package/dist/bulk.builder.d.ts.map +1 -1
- package/dist/bulk.builder.js +1 -1
- package/dist/field.helpers.d.ts +39 -44
- package/dist/field.helpers.d.ts.map +1 -1
- package/dist/field.helpers.js +15 -19
- package/dist/field.types.d.ts +35 -5
- package/dist/field.types.d.ts.map +1 -1
- package/dist/field.types.js +3 -3
- package/dist/index-management.builder.d.ts +5 -12
- package/dist/index-management.builder.d.ts.map +1 -1
- package/dist/index-management.builder.js +10 -32
- package/dist/index-management.types.d.ts +10 -64
- package/dist/index-management.types.d.ts.map +1 -1
- package/dist/index-management.types.js +0 -1
- package/dist/index.d.ts +16 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/mapping.builder.d.ts +24 -0
- package/dist/mapping.builder.d.ts.map +1 -0
- package/dist/mapping.builder.js +23 -0
- package/dist/mapping.types.d.ts +82 -0
- package/dist/mapping.types.d.ts.map +1 -0
- package/dist/mapping.types.js +6 -0
- package/dist/multi-search.builder.d.ts +5 -3
- package/dist/multi-search.builder.d.ts.map +1 -1
- package/dist/multi-search.builder.js +2 -2
- package/dist/multi-search.types.d.ts +7 -6
- package/dist/multi-search.types.d.ts.map +1 -1
- package/dist/query.builder.d.ts +3 -7
- package/dist/query.builder.d.ts.map +1 -1
- package/dist/query.builder.js +29 -91
- package/dist/query.types.d.ts +85 -235
- package/dist/query.types.d.ts.map +1 -1
- package/dist/query.types.js +2 -1
- package/dist/suggester.builder.d.ts +5 -3
- package/dist/suggester.builder.d.ts.map +1 -1
- package/dist/suggester.builder.js +2 -2
- package/dist/suggester.types.d.ts +5 -4
- package/dist/suggester.types.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregation.types.d.ts","sourceRoot":"","sources":["../src/aggregation.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,4BAA4B,EAC5B,gCAAgC,EAChC,8BAA8B,EAC9B,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC1B,kCAAkC,EAClC,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EACjC,4BAA4B,EAC7B,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"aggregation.types.d.ts","sourceRoot":"","sources":["../src/aggregation.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACpC,4BAA4B,EAC5B,gCAAgC,EAChC,8BAA8B,EAC9B,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC1B,kCAAkC,EAClC,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EACjC,4BAA4B,EAC7B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,oCAAoC,EACpC,OAAO,CACR,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAA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CAAC,CAAC,CAAC;IAE3B,oDAAoD;IACpD,WAAW,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,EACtC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,qBAAqB,KAC5B,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAE3B,8BAA8B;IAC9B,WAAW,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,EACtC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,qBAAqB,KAC5B,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAE3B,yDAAyD;IACzD,KAAK,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,EAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,eAAe,KACtB,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAE3B,8BAA8B;IAC9B,UAAU,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,oBAAoB,KAC3B,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAE3B,uDAAuD;IACvD,MAAM,EAAE,CACN,EAAE,EAAE,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,KACtD,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAE3B,4BAA4B;IAC5B,KAAK,EAAE,MAAM,gBAAgB,CAAC;CAC/B,CAAC"}
|
package/dist/bulk.builder.d.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Bulk API builder
|
|
3
3
|
* Enables batching multiple index/create/update/delete operations
|
|
4
4
|
*/
|
|
5
|
+
import type { FieldTypeString } from './index-management.types.js';
|
|
6
|
+
import type { MappingsSchema } from './mapping.types.js';
|
|
5
7
|
import { BulkBuilder } from './bulk.types.js';
|
|
6
8
|
/**
|
|
7
9
|
* Creates a bulk operations builder
|
|
@@ -20,5 +22,117 @@ export declare const createBulkBuilder: <T>(operations?: any[]) => BulkBuilder<T
|
|
|
20
22
|
* .delete({ _index: 'products', _id: '4' })
|
|
21
23
|
* .build(); // POST to /_bulk with Content-Type: application/x-ndjson
|
|
22
24
|
*/
|
|
23
|
-
export declare const bulk: <
|
|
25
|
+
export declare const bulk: <M extends Record<string, FieldTypeString>>(_schema: MappingsSchema<M>) => BulkBuilder<{ [K in keyof M]: M[K] extends keyof {
|
|
26
|
+
text: string;
|
|
27
|
+
keyword: string;
|
|
28
|
+
long: number;
|
|
29
|
+
integer: number;
|
|
30
|
+
short: number;
|
|
31
|
+
byte: number;
|
|
32
|
+
float: number;
|
|
33
|
+
double: number;
|
|
34
|
+
half_float: number;
|
|
35
|
+
scaled_float: number;
|
|
36
|
+
date: string;
|
|
37
|
+
boolean: boolean;
|
|
38
|
+
binary: string;
|
|
39
|
+
ip: string;
|
|
40
|
+
geo_point: {
|
|
41
|
+
lat: number;
|
|
42
|
+
lon: number;
|
|
43
|
+
};
|
|
44
|
+
geo_shape: Record<string, unknown>;
|
|
45
|
+
dense_vector: number[];
|
|
46
|
+
completion: string;
|
|
47
|
+
nested: unknown;
|
|
48
|
+
object: unknown;
|
|
49
|
+
alias: unknown;
|
|
50
|
+
percolator: unknown;
|
|
51
|
+
integer_range: {
|
|
52
|
+
gte?: number;
|
|
53
|
+
lte?: number;
|
|
54
|
+
gt?: number;
|
|
55
|
+
lt?: number;
|
|
56
|
+
};
|
|
57
|
+
float_range: {
|
|
58
|
+
gte?: number;
|
|
59
|
+
lte?: number;
|
|
60
|
+
gt?: number;
|
|
61
|
+
lt?: number;
|
|
62
|
+
};
|
|
63
|
+
long_range: {
|
|
64
|
+
gte?: number;
|
|
65
|
+
lte?: number;
|
|
66
|
+
gt?: number;
|
|
67
|
+
lt?: number;
|
|
68
|
+
};
|
|
69
|
+
double_range: {
|
|
70
|
+
gte?: number;
|
|
71
|
+
lte?: number;
|
|
72
|
+
gt?: number;
|
|
73
|
+
lt?: number;
|
|
74
|
+
};
|
|
75
|
+
date_range: {
|
|
76
|
+
gte?: string;
|
|
77
|
+
lte?: string;
|
|
78
|
+
gt?: string;
|
|
79
|
+
lt?: string;
|
|
80
|
+
};
|
|
81
|
+
} ? {
|
|
82
|
+
text: string;
|
|
83
|
+
keyword: string;
|
|
84
|
+
long: number;
|
|
85
|
+
integer: number;
|
|
86
|
+
short: number;
|
|
87
|
+
byte: number;
|
|
88
|
+
float: number;
|
|
89
|
+
double: number;
|
|
90
|
+
half_float: number;
|
|
91
|
+
scaled_float: number;
|
|
92
|
+
date: string;
|
|
93
|
+
boolean: boolean;
|
|
94
|
+
binary: string;
|
|
95
|
+
ip: string;
|
|
96
|
+
geo_point: {
|
|
97
|
+
lat: number;
|
|
98
|
+
lon: number;
|
|
99
|
+
};
|
|
100
|
+
geo_shape: Record<string, unknown>;
|
|
101
|
+
dense_vector: number[];
|
|
102
|
+
completion: string;
|
|
103
|
+
nested: unknown;
|
|
104
|
+
object: unknown;
|
|
105
|
+
alias: unknown;
|
|
106
|
+
percolator: unknown;
|
|
107
|
+
integer_range: {
|
|
108
|
+
gte?: number;
|
|
109
|
+
lte?: number;
|
|
110
|
+
gt?: number;
|
|
111
|
+
lt?: number;
|
|
112
|
+
};
|
|
113
|
+
float_range: {
|
|
114
|
+
gte?: number;
|
|
115
|
+
lte?: number;
|
|
116
|
+
gt?: number;
|
|
117
|
+
lt?: number;
|
|
118
|
+
};
|
|
119
|
+
long_range: {
|
|
120
|
+
gte?: number;
|
|
121
|
+
lte?: number;
|
|
122
|
+
gt?: number;
|
|
123
|
+
lt?: number;
|
|
124
|
+
};
|
|
125
|
+
double_range: {
|
|
126
|
+
gte?: number;
|
|
127
|
+
lte?: number;
|
|
128
|
+
gt?: number;
|
|
129
|
+
lt?: number;
|
|
130
|
+
};
|
|
131
|
+
date_range: {
|
|
132
|
+
gte?: string;
|
|
133
|
+
lte?: string;
|
|
134
|
+
gt?: string;
|
|
135
|
+
lt?: string;
|
|
136
|
+
};
|
|
137
|
+
}[M[K]] : unknown; }>;
|
|
24
138
|
//# sourceMappingURL=bulk.builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk.builder.d.ts","sourceRoot":"","sources":["../src/bulk.builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAEjC,aAAY,GAAG,EAAO,KACrB,WAAW,CAAC,CAAC,CA8Bd,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"bulk.builder.d.ts","sourceRoot":"","sources":["../src/bulk.builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAEjC,aAAY,GAAG,EAAO,KACrB,WAAW,CAAC,CAAC,CA8Bd,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAC5D,SAAS,cAAc,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;WAnBiC,CAAC;WAC5D,CAAC;UAEM,CAAC;UAAY,CAAC;;;WAIP,CAAA;WAAa,CAAC;UAC7B,CAAC;UAAY,CAAC;;;WAA+B,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAC1D,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAChE,CAAC;WACE,CAAA;UAAY,CAAC;UACrB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAZ4D,CAAC;WAC5D,CAAC;UAEM,CAAC;UAAY,CAAC;;;WAIP,CAAA;WAAa,CAAC;UAC7B,CAAC;UAAY,CAAC;;;WAA+B,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAC1D,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAChE,CAAC;WACE,CAAA;UAAY,CAAC;UACrB,CAAA;;qBAQiD,CAAC"}
|
package/dist/bulk.builder.js
CHANGED
package/dist/field.helpers.d.ts
CHANGED
|
@@ -1,51 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Field type helper functions for ergonomic index mapping definitions.
|
|
3
|
-
* Each helper returns a
|
|
4
|
-
*
|
|
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
5
|
*
|
|
6
6
|
* @example
|
|
7
|
-
* import { text, keyword, denseVector } from 'elasticlink';
|
|
7
|
+
* import { text, keyword, denseVector, mappings } from 'elasticlink';
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* })
|
|
9
|
+
* const productMappings = mappings({
|
|
10
|
+
* name: text({ analyzer: 'standard' }),
|
|
11
|
+
* price: float(),
|
|
12
|
+
* category: keyword(),
|
|
13
|
+
* embedding: denseVector({ dims: 384 }),
|
|
14
|
+
* });
|
|
16
15
|
*/
|
|
17
|
-
import type { FieldMapping
|
|
18
|
-
import type { TextFieldOptions, KeywordFieldOptions, NumericFieldOptions, ScaledFloatFieldOptions, DateFieldOptions, BooleanFieldOptions, DenseVectorFieldOptions, NestedFields, ObjectFieldOptions, CompletionFieldOptions, GeoPointFieldOptions, GeoShapeFieldOptions, AliasFieldOptions, IpFieldOptions, RangeFieldOptions } from './field.types.js';
|
|
19
|
-
export declare const text: (options?: TextFieldOptions) =>
|
|
20
|
-
export declare const keyword: (options?: KeywordFieldOptions) =>
|
|
21
|
-
export declare const long: (options?: NumericFieldOptions) =>
|
|
22
|
-
export declare const integer: (options?: NumericFieldOptions) =>
|
|
23
|
-
export declare const short: (options?: NumericFieldOptions) =>
|
|
24
|
-
export declare const byte: (options?: NumericFieldOptions) =>
|
|
25
|
-
export declare const double: (options?: NumericFieldOptions) =>
|
|
26
|
-
export declare const float: (options?: NumericFieldOptions) =>
|
|
27
|
-
export declare const halfFloat: (options?: NumericFieldOptions) =>
|
|
28
|
-
export declare const scaledFloat: (options?: ScaledFloatFieldOptions) =>
|
|
29
|
-
export declare const date: (options?: DateFieldOptions) =>
|
|
30
|
-
export declare const boolean: (options?: BooleanFieldOptions) =>
|
|
31
|
-
export declare const binary: () =>
|
|
32
|
-
export declare const ip: (options?: IpFieldOptions) =>
|
|
33
|
-
export declare const denseVector: (options?: DenseVectorFieldOptions) =>
|
|
34
|
-
export declare const geoPoint: (options?: GeoPointFieldOptions) =>
|
|
35
|
-
export declare const geoShape: (options?: GeoShapeFieldOptions) =>
|
|
36
|
-
export declare const completion: (options?: CompletionFieldOptions) =>
|
|
37
|
-
export declare const nested: (fields?: NestedFields) =>
|
|
38
|
-
export declare const object: (fields?: NestedFields, options?: ObjectFieldOptions) =>
|
|
39
|
-
export declare const alias: (options?: AliasFieldOptions) =>
|
|
40
|
-
export declare const percolator: () =>
|
|
41
|
-
export declare const integerRange: (options?: RangeFieldOptions) =>
|
|
42
|
-
export declare const floatRange: (options?: RangeFieldOptions) =>
|
|
43
|
-
export declare const longRange: (options?: RangeFieldOptions) =>
|
|
44
|
-
export declare const doubleRange: (options?: RangeFieldOptions) =>
|
|
45
|
-
export declare const dateRange: (options?: RangeFieldOptions) =>
|
|
46
|
-
|
|
47
|
-
* Resolves a FieldMappingInput to a FieldMapping.
|
|
48
|
-
* Converts shorthand strings like 'text' to { type: 'text' }.
|
|
49
|
-
*/
|
|
50
|
-
export declare const resolveField: (input: FieldMappingInput) => FieldMapping;
|
|
16
|
+
import type { FieldMapping } from './index-management.types.js';
|
|
17
|
+
import type { TextFieldOptions, KeywordFieldOptions, NumericFieldOptions, ScaledFloatFieldOptions, DateFieldOptions, BooleanFieldOptions, DenseVectorFieldOptions, NestedFields, ObjectFieldOptions, CompletionFieldOptions, GeoPointFieldOptions, GeoShapeFieldOptions, AliasFieldOptions, IpFieldOptions, RangeFieldOptions, TextFieldMapping, KeywordFieldMapping, LongFieldMapping, IntegerFieldMapping, ShortFieldMapping, ByteFieldMapping, DoubleFieldMapping, FloatFieldMapping, HalfFloatFieldMapping, ScaledFloatFieldMapping, DateFieldMapping, BooleanFieldMapping, BinaryFieldMapping, IpFieldMapping, DenseVectorFieldMapping, GeoPointFieldMapping, GeoShapeFieldMapping, CompletionFieldMapping, NestedFieldMapping, ObjectFieldMapping, AliasFieldMapping, PercolatorFieldMapping, IntegerRangeFieldMapping, FloatRangeFieldMapping, LongRangeFieldMapping, DoubleRangeFieldMapping, DateRangeFieldMapping } from './field.types.js';
|
|
18
|
+
export declare const text: (options?: TextFieldOptions) => TextFieldMapping;
|
|
19
|
+
export declare const keyword: (options?: KeywordFieldOptions) => KeywordFieldMapping;
|
|
20
|
+
export declare const long: (options?: NumericFieldOptions) => LongFieldMapping;
|
|
21
|
+
export declare const integer: (options?: NumericFieldOptions) => IntegerFieldMapping;
|
|
22
|
+
export declare const short: (options?: NumericFieldOptions) => ShortFieldMapping;
|
|
23
|
+
export declare const byte: (options?: NumericFieldOptions) => ByteFieldMapping;
|
|
24
|
+
export declare const double: (options?: NumericFieldOptions) => DoubleFieldMapping;
|
|
25
|
+
export declare const float: (options?: NumericFieldOptions) => FloatFieldMapping;
|
|
26
|
+
export declare const halfFloat: (options?: NumericFieldOptions) => HalfFloatFieldMapping;
|
|
27
|
+
export declare const scaledFloat: (options?: ScaledFloatFieldOptions) => ScaledFloatFieldMapping;
|
|
28
|
+
export declare const date: (options?: DateFieldOptions) => DateFieldMapping;
|
|
29
|
+
export declare const boolean: (options?: BooleanFieldOptions) => BooleanFieldMapping;
|
|
30
|
+
export declare const binary: () => BinaryFieldMapping;
|
|
31
|
+
export declare const ip: (options?: IpFieldOptions) => IpFieldMapping;
|
|
32
|
+
export declare const denseVector: (options?: DenseVectorFieldOptions) => DenseVectorFieldMapping;
|
|
33
|
+
export declare const geoPoint: (options?: GeoPointFieldOptions) => GeoPointFieldMapping;
|
|
34
|
+
export declare const geoShape: (options?: GeoShapeFieldOptions) => GeoShapeFieldMapping;
|
|
35
|
+
export declare const completion: (options?: CompletionFieldOptions) => CompletionFieldMapping;
|
|
36
|
+
export declare const nested: (fields?: NestedFields) => NestedFieldMapping;
|
|
37
|
+
export declare const object: (fields?: NestedFields, options?: ObjectFieldOptions) => ObjectFieldMapping;
|
|
38
|
+
export declare const alias: (options?: AliasFieldOptions) => AliasFieldMapping;
|
|
39
|
+
export declare const percolator: () => PercolatorFieldMapping;
|
|
40
|
+
export declare const integerRange: (options?: RangeFieldOptions) => IntegerRangeFieldMapping;
|
|
41
|
+
export declare const floatRange: (options?: RangeFieldOptions) => FloatRangeFieldMapping;
|
|
42
|
+
export declare const longRange: (options?: RangeFieldOptions) => LongRangeFieldMapping;
|
|
43
|
+
export declare const doubleRange: (options?: RangeFieldOptions) => DoubleRangeFieldMapping;
|
|
44
|
+
export declare const dateRange: (options?: RangeFieldOptions) => DateRangeFieldMapping;
|
|
45
|
+
export declare const resolveField: (input: FieldMapping) => FieldMapping;
|
|
51
46
|
//# sourceMappingURL=field.helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.helpers.d.ts","sourceRoot":"","sources":["../src/field.helpers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"field.helpers.d.ts","sourceRoot":"","sources":["../src/field.help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eAAO,MAAM,YAAY,GAAI,OAAO,YAAY,KAAG,YAAqB,CAAC"}
|
package/dist/field.helpers.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Field type helper functions for ergonomic index mapping definitions.
|
|
3
|
-
* Each helper returns a
|
|
4
|
-
*
|
|
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
5
|
*
|
|
6
6
|
* @example
|
|
7
|
-
* import { text, keyword, denseVector } from 'elasticlink';
|
|
7
|
+
* import { text, keyword, denseVector, mappings } from 'elasticlink';
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* })
|
|
9
|
+
* const productMappings = mappings({
|
|
10
|
+
* name: text({ analyzer: 'standard' }),
|
|
11
|
+
* price: float(),
|
|
12
|
+
* category: keyword(),
|
|
13
|
+
* embedding: denseVector({ dims: 384 }),
|
|
14
|
+
* });
|
|
16
15
|
*/
|
|
17
16
|
// Text & keyword
|
|
18
17
|
export const text = (options) => ({
|
|
@@ -88,12 +87,12 @@ export const completion = (options) => ({
|
|
|
88
87
|
// Structured
|
|
89
88
|
export const nested = (fields) => ({
|
|
90
89
|
type: 'nested',
|
|
91
|
-
...(fields && { properties:
|
|
90
|
+
...(fields && { properties: fields })
|
|
92
91
|
});
|
|
93
92
|
export const object = (fields, options) => ({
|
|
94
93
|
type: 'object',
|
|
95
94
|
...(options?.enabled !== undefined && { enabled: options.enabled }),
|
|
96
|
-
...(fields && { properties:
|
|
95
|
+
...(fields && { properties: fields })
|
|
97
96
|
});
|
|
98
97
|
// Alias
|
|
99
98
|
export const alias = (options) => ({
|
|
@@ -101,7 +100,9 @@ export const alias = (options) => ({
|
|
|
101
100
|
...options
|
|
102
101
|
});
|
|
103
102
|
// Percolator
|
|
104
|
-
export const percolator = () => ({
|
|
103
|
+
export const percolator = () => ({
|
|
104
|
+
type: 'percolator'
|
|
105
|
+
});
|
|
105
106
|
// Range types
|
|
106
107
|
export const integerRange = (options) => ({
|
|
107
108
|
type: 'integer_range',
|
|
@@ -123,9 +124,4 @@ export const dateRange = (options) => ({
|
|
|
123
124
|
type: 'date_range',
|
|
124
125
|
...options
|
|
125
126
|
});
|
|
126
|
-
|
|
127
|
-
* Resolves a FieldMappingInput to a FieldMapping.
|
|
128
|
-
* Converts shorthand strings like 'text' to { type: 'text' }.
|
|
129
|
-
*/
|
|
130
|
-
export const resolveField = (input) => typeof input === 'string' ? { type: input } : input;
|
|
131
|
-
const resolveProperties = (props) => Object.fromEntries(Object.entries(props).map(([k, v]) => [k, resolveField(v)]));
|
|
127
|
+
export const resolveField = (input) => input;
|
package/dist/field.types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-field-type option types
|
|
3
|
-
* Each
|
|
4
|
-
*
|
|
2
|
+
* Per-field-type option types and narrowly-typed mapping return types.
|
|
3
|
+
* Each helper function returns a mapping with a literal `type` field,
|
|
4
|
+
* enabling compile-time field-type inference in the query builder.
|
|
5
5
|
*/
|
|
6
|
-
import type { FieldMapping
|
|
6
|
+
import type { FieldMapping } from './index-management.types.js';
|
|
7
7
|
/** Options for text fields */
|
|
8
8
|
export type TextFieldOptions = {
|
|
9
9
|
analyzer?: string;
|
|
@@ -63,7 +63,7 @@ export type DenseVectorFieldOptions = {
|
|
|
63
63
|
similarity?: 'cosine' | 'dot_product' | 'l2_norm' | 'max_inner_product';
|
|
64
64
|
};
|
|
65
65
|
/** Sub-fields for nested and object field types */
|
|
66
|
-
export type NestedFields = Record<string,
|
|
66
|
+
export type NestedFields = Record<string, FieldMapping>;
|
|
67
67
|
/** Options for object fields (enabled flag only — sub-fields are the first argument) */
|
|
68
68
|
export type ObjectFieldOptions = {
|
|
69
69
|
enabled?: boolean;
|
|
@@ -109,4 +109,34 @@ export type RangeFieldOptions = {
|
|
|
109
109
|
doc_values?: boolean;
|
|
110
110
|
coerce?: boolean;
|
|
111
111
|
};
|
|
112
|
+
export type TypedFieldMapping<T extends string> = Omit<FieldMapping, 'type'> & {
|
|
113
|
+
type: T;
|
|
114
|
+
};
|
|
115
|
+
export type TextFieldMapping = TypedFieldMapping<'text'>;
|
|
116
|
+
export type KeywordFieldMapping = TypedFieldMapping<'keyword'>;
|
|
117
|
+
export type LongFieldMapping = TypedFieldMapping<'long'>;
|
|
118
|
+
export type IntegerFieldMapping = TypedFieldMapping<'integer'>;
|
|
119
|
+
export type ShortFieldMapping = TypedFieldMapping<'short'>;
|
|
120
|
+
export type ByteFieldMapping = TypedFieldMapping<'byte'>;
|
|
121
|
+
export type DoubleFieldMapping = TypedFieldMapping<'double'>;
|
|
122
|
+
export type FloatFieldMapping = TypedFieldMapping<'float'>;
|
|
123
|
+
export type HalfFloatFieldMapping = TypedFieldMapping<'half_float'>;
|
|
124
|
+
export type ScaledFloatFieldMapping = TypedFieldMapping<'scaled_float'>;
|
|
125
|
+
export type DateFieldMapping = TypedFieldMapping<'date'>;
|
|
126
|
+
export type BooleanFieldMapping = TypedFieldMapping<'boolean'>;
|
|
127
|
+
export type BinaryFieldMapping = TypedFieldMapping<'binary'>;
|
|
128
|
+
export type IpFieldMapping = TypedFieldMapping<'ip'>;
|
|
129
|
+
export type DenseVectorFieldMapping = TypedFieldMapping<'dense_vector'>;
|
|
130
|
+
export type GeoPointFieldMapping = TypedFieldMapping<'geo_point'>;
|
|
131
|
+
export type GeoShapeFieldMapping = TypedFieldMapping<'geo_shape'>;
|
|
132
|
+
export type CompletionFieldMapping = TypedFieldMapping<'completion'>;
|
|
133
|
+
export type NestedFieldMapping = TypedFieldMapping<'nested'>;
|
|
134
|
+
export type ObjectFieldMapping = TypedFieldMapping<'object'>;
|
|
135
|
+
export type AliasFieldMapping = TypedFieldMapping<'alias'>;
|
|
136
|
+
export type PercolatorFieldMapping = TypedFieldMapping<'percolator'>;
|
|
137
|
+
export type IntegerRangeFieldMapping = TypedFieldMapping<'integer_range'>;
|
|
138
|
+
export type FloatRangeFieldMapping = TypedFieldMapping<'float_range'>;
|
|
139
|
+
export type LongRangeFieldMapping = TypedFieldMapping<'long_range'>;
|
|
140
|
+
export type DoubleRangeFieldMapping = TypedFieldMapping<'double_range'>;
|
|
141
|
+
export type DateRangeFieldMapping = TypedFieldMapping<'date_range'>;
|
|
112
142
|
//# sourceMappingURL=field.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.types.d.ts","sourceRoot":"","sources":["../src/field.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"field.types.d.ts","sourceRoot":"","sources":["../src/field.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,8BAA8B;AAC9B,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACvC,CAAC;AAEF,iCAAiC;AACjC,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MA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c,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACrD,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;AACxE,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAClE,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAClE,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;AACrE,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAC7D,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAC7D,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAC3D,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;AACrE,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,CAAC,eAAe,CAAC,CAAC;AAC1E,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AACtE,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;AACpE,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;AACxE,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC"}
|
package/dist/field.types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-field-type option types
|
|
3
|
-
* Each
|
|
4
|
-
*
|
|
2
|
+
* Per-field-type option types and narrowly-typed mapping return types.
|
|
3
|
+
* Each helper function returns a mapping with a literal `type` field,
|
|
4
|
+
* enabling compile-time field-type inference in the query builder.
|
|
5
5
|
*/
|
|
6
6
|
export {};
|
|
@@ -7,22 +7,15 @@ import type { IndexBuilder, CreateIndexOptions } from './index-management.types.
|
|
|
7
7
|
* Creates an index builder
|
|
8
8
|
* @returns IndexBuilder instance
|
|
9
9
|
*/
|
|
10
|
-
export declare const createIndexBuilder:
|
|
10
|
+
export declare const createIndexBuilder: (state?: CreateIndexOptions) => IndexBuilder;
|
|
11
11
|
/**
|
|
12
12
|
* Create a new index builder
|
|
13
13
|
* @example
|
|
14
|
-
* const indexConfig = indexBuilder
|
|
15
|
-
* .mappings(
|
|
16
|
-
*
|
|
17
|
-
* price: 'float',
|
|
18
|
-
* category: 'keyword',
|
|
19
|
-
* })
|
|
20
|
-
* .settings({
|
|
21
|
-
* number_of_shards: 1,
|
|
22
|
-
* number_of_replicas: 1
|
|
23
|
-
* })
|
|
14
|
+
* const indexConfig = indexBuilder()
|
|
15
|
+
* .mappings(productMappings)
|
|
16
|
+
* .settings({ number_of_shards: 1, number_of_replicas: 1 })
|
|
24
17
|
* .alias('products_alias')
|
|
25
18
|
* .build();
|
|
26
19
|
*/
|
|
27
|
-
export declare const indexBuilder:
|
|
20
|
+
export declare const indexBuilder: () => IndexBuilder;
|
|
28
21
|
//# sourceMappingURL=index-management.builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-management.builder.d.ts","sourceRoot":"","sources":["../src/index-management.builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index-management.builder.d.ts","sourceRoot":"","sources":["../src/index-management.builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAGV,YAAY,EACZ,kBAAkB,EACnB,MAAM,6BAA6B,CAAC;AAUrC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC7B,QAAO,kBAAuB,KAC7B,YAsBD,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,oBAA6B,CAAC"}
|
|
@@ -2,37 +2,22 @@
|
|
|
2
2
|
* Index Management builder
|
|
3
3
|
* Create and configure Elasticsearch indices
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
/** Resolves MappingsInput<T> to the ES-compatible IndexMappings<T> */
|
|
7
|
-
const resolveMappings = (input) => {
|
|
8
|
-
const { dynamic, dynamic_templates, ...fields } = input;
|
|
9
|
-
const properties = {};
|
|
10
|
-
for (const [key, value] of Object.entries(fields)) {
|
|
11
|
-
if (value !== undefined) {
|
|
12
|
-
properties[key] = resolveField(value);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
const mappings = { properties };
|
|
16
|
-
if (dynamic !== undefined)
|
|
17
|
-
mappings.dynamic = dynamic;
|
|
18
|
-
if (dynamic_templates !== undefined)
|
|
19
|
-
mappings.dynamic_templates = dynamic_templates;
|
|
20
|
-
return mappings;
|
|
21
|
-
};
|
|
5
|
+
const isMappingsSchema = (input) => '_fieldTypes' in input;
|
|
22
6
|
/**
|
|
23
7
|
* Creates an index builder
|
|
24
8
|
* @returns IndexBuilder instance
|
|
25
9
|
*/
|
|
26
10
|
export const createIndexBuilder = (state = {}) => ({
|
|
27
|
-
mappings: (
|
|
11
|
+
mappings: (schemaOrFields) => {
|
|
12
|
+
const properties = isMappingsSchema(schemaOrFields)
|
|
13
|
+
? schemaOrFields.properties
|
|
14
|
+
: schemaOrFields;
|
|
28
15
|
return createIndexBuilder({
|
|
29
16
|
...state,
|
|
30
|
-
mappings:
|
|
17
|
+
mappings: { properties }
|
|
31
18
|
});
|
|
32
19
|
},
|
|
33
|
-
settings: (settings) => {
|
|
34
|
-
return createIndexBuilder({ ...state, settings });
|
|
35
|
-
},
|
|
20
|
+
settings: (settings) => createIndexBuilder({ ...state, settings }),
|
|
36
21
|
alias: (name, options = {}) => {
|
|
37
22
|
const aliases = state.aliases || {};
|
|
38
23
|
return createIndexBuilder({
|
|
@@ -45,16 +30,9 @@ export const createIndexBuilder = (state = {}) => ({
|
|
|
45
30
|
/**
|
|
46
31
|
* Create a new index builder
|
|
47
32
|
* @example
|
|
48
|
-
* const indexConfig = indexBuilder
|
|
49
|
-
* .mappings(
|
|
50
|
-
*
|
|
51
|
-
* price: 'float',
|
|
52
|
-
* category: 'keyword',
|
|
53
|
-
* })
|
|
54
|
-
* .settings({
|
|
55
|
-
* number_of_shards: 1,
|
|
56
|
-
* number_of_replicas: 1
|
|
57
|
-
* })
|
|
33
|
+
* const indexConfig = indexBuilder()
|
|
34
|
+
* .mappings(productMappings)
|
|
35
|
+
* .settings({ number_of_shards: 1, number_of_replicas: 1 })
|
|
58
36
|
* .alias('products_alias')
|
|
59
37
|
* .build();
|
|
60
38
|
*/
|