elasticlink 0.2.2-beta → 0.4.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 +223 -177
- package/dist/__tests__/aggregation-builder.test.d.ts +2 -0
- package/dist/__tests__/aggregation-builder.test.d.ts.map +1 -0
- package/dist/__tests__/aggregation-builder.test.js +622 -0
- package/dist/__tests__/bulk.test.d.ts +2 -0
- package/dist/__tests__/bulk.test.d.ts.map +1 -0
- package/dist/__tests__/bulk.test.js +679 -0
- package/dist/__tests__/examples.test.d.ts +2 -0
- package/dist/__tests__/examples.test.d.ts.map +1 -0
- package/dist/__tests__/examples.test.js +2123 -0
- package/dist/__tests__/fixtures/finance.d.ts +58 -0
- package/dist/__tests__/fixtures/finance.d.ts.map +1 -0
- package/dist/__tests__/fixtures/finance.js +73 -0
- package/dist/__tests__/fixtures/legal.d.ts +14 -0
- package/dist/__tests__/fixtures/legal.d.ts.map +1 -0
- package/dist/__tests__/fixtures/legal.js +27 -0
- package/dist/__tests__/fixtures/real-estate.d.ts +31 -0
- package/dist/__tests__/fixtures/real-estate.d.ts.map +1 -0
- package/dist/__tests__/fixtures/real-estate.js +39 -0
- package/dist/__tests__/index-management.test.d.ts +2 -0
- package/dist/__tests__/index-management.test.d.ts.map +1 -0
- package/dist/__tests__/index-management.test.js +1699 -0
- package/dist/__tests__/integration/aggregation.integration.test.d.ts +2 -0
- package/dist/__tests__/integration/aggregation.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/aggregation.integration.test.js +188 -0
- package/dist/__tests__/integration/bulk.integration.test.d.ts +2 -0
- package/dist/__tests__/integration/bulk.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/bulk.integration.test.js +90 -0
- package/dist/__tests__/integration/fixtures/finance.d.ts +37 -0
- package/dist/__tests__/integration/fixtures/finance.d.ts.map +1 -0
- package/dist/__tests__/integration/fixtures/finance.js +58 -0
- package/dist/__tests__/integration/fixtures/legal.d.ts +38 -0
- package/dist/__tests__/integration/fixtures/legal.d.ts.map +1 -0
- package/dist/__tests__/integration/fixtures/legal.js +65 -0
- package/dist/__tests__/integration/fixtures/real-estate.d.ts +17 -0
- package/dist/__tests__/integration/fixtures/real-estate.d.ts.map +1 -0
- package/dist/__tests__/integration/fixtures/real-estate.js +28 -0
- package/dist/__tests__/integration/helpers.d.ts +15 -0
- package/dist/__tests__/integration/helpers.d.ts.map +1 -0
- package/dist/__tests__/integration/helpers.js +21 -0
- package/dist/__tests__/integration/index-management.integration.test.d.ts +2 -0
- package/dist/__tests__/integration/index-management.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/index-management.integration.test.js +67 -0
- package/dist/__tests__/integration/multi-search.integration.test.d.ts +2 -0
- package/dist/__tests__/integration/multi-search.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/multi-search.integration.test.js +49 -0
- package/dist/__tests__/integration/query.integration.test.d.ts +2 -0
- package/dist/__tests__/integration/query.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/query.integration.test.js +101 -0
- package/dist/__tests__/integration/suggester.integration.test.d.ts +2 -0
- package/dist/__tests__/integration/suggester.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/suggester.integration.test.js +42 -0
- package/dist/__tests__/multi-search.test.d.ts +2 -0
- package/dist/__tests__/multi-search.test.d.ts.map +1 -0
- package/dist/__tests__/multi-search.test.js +325 -0
- package/dist/__tests__/query-builder-extensions.test.d.ts +2 -0
- package/dist/__tests__/query-builder-extensions.test.d.ts.map +1 -0
- package/dist/__tests__/query-builder-extensions.test.js +436 -0
- package/dist/__tests__/query-builder.test.d.ts +2 -0
- package/dist/__tests__/query-builder.test.d.ts.map +1 -0
- package/dist/__tests__/query-builder.test.js +5482 -0
- package/dist/__tests__/settings-presets.test.d.ts +2 -0
- package/dist/__tests__/settings-presets.test.d.ts.map +1 -0
- package/dist/__tests__/settings-presets.test.js +183 -0
- package/dist/__tests__/suggester.test.d.ts +2 -0
- package/dist/__tests__/suggester.test.d.ts.map +1 -0
- package/dist/__tests__/suggester.test.js +1006 -0
- package/dist/aggregation.builder.d.ts +4 -2
- package/dist/aggregation.builder.d.ts.map +1 -1
- package/dist/aggregation.builder.js +102 -95
- package/dist/aggregation.types.d.ts +16 -14
- package/dist/aggregation.types.d.ts.map +1 -1
- package/dist/bulk.builder.d.ts +126 -2
- package/dist/bulk.builder.d.ts.map +1 -1
- package/dist/bulk.builder.js +11 -12
- package/dist/bulk.types.d.ts.map +1 -1
- package/dist/field.helpers.d.ts +92 -42
- package/dist/field.helpers.d.ts.map +1 -1
- package/dist/field.helpers.js +99 -20
- package/dist/field.types.d.ts +113 -6
- package/dist/field.types.d.ts.map +1 -1
- package/dist/field.types.js +3 -3
- package/dist/index-management.builder.d.ts +19 -14
- package/dist/index-management.builder.d.ts.map +1 -1
- package/dist/index-management.builder.js +36 -34
- package/dist/index-management.types.d.ts +32 -62
- package/dist/index-management.types.d.ts.map +1 -1
- package/dist/index-management.types.js +0 -1
- package/dist/index.d.ts +18 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -8
- package/dist/mapping.builder.d.ts +37 -0
- package/dist/mapping.builder.d.ts.map +1 -0
- package/dist/mapping.builder.js +38 -0
- package/dist/mapping.types.d.ts +105 -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 +6 -4
- 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 -11
- package/dist/query.builder.d.ts.map +1 -1
- package/dist/query.builder.js +118 -259
- package/dist/query.types.d.ts +140 -236
- package/dist/query.types.d.ts.map +1 -1
- package/dist/query.types.js +2 -1
- package/dist/settings.presets.d.ts +98 -0
- package/dist/settings.presets.d.ts.map +1 -0
- package/dist/settings.presets.js +115 -0
- package/dist/suggester.builder.d.ts +5 -3
- package/dist/suggester.builder.d.ts.map +1 -1
- package/dist/suggester.builder.js +3 -2
- package/dist/suggester.types.d.ts +5 -4
- package/dist/suggester.types.d.ts.map +1 -1
- package/dist/vector.types.d.ts.map +1 -1
- package/package.json +12 -9
package/dist/field.helpers.d.ts
CHANGED
|
@@ -1,51 +1,101 @@
|
|
|
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 {
|
|
18
|
-
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
27
|
-
export declare const
|
|
28
|
-
export declare const
|
|
29
|
-
export declare const
|
|
30
|
-
export declare const
|
|
31
|
-
export declare const
|
|
32
|
-
export declare const
|
|
33
|
-
export declare const denseVector: (options?: DenseVectorFieldOptions) => FieldMapping;
|
|
34
|
-
export declare const geoPoint: (options?: GeoPointFieldOptions) => FieldMapping;
|
|
35
|
-
export declare const geoShape: (options?: GeoShapeFieldOptions) => FieldMapping;
|
|
36
|
-
export declare const completion: (options?: CompletionFieldOptions) => FieldMapping;
|
|
37
|
-
export declare const nested: (fields?: NestedFields) => FieldMapping;
|
|
38
|
-
export declare const object: (fields?: NestedFields, options?: ObjectFieldOptions) => FieldMapping;
|
|
39
|
-
export declare const alias: (options?: AliasFieldOptions) => FieldMapping;
|
|
40
|
-
export declare const percolator: () => FieldMapping;
|
|
41
|
-
export declare const integerRange: (options?: RangeFieldOptions) => FieldMapping;
|
|
42
|
-
export declare const floatRange: (options?: RangeFieldOptions) => FieldMapping;
|
|
43
|
-
export declare const longRange: (options?: RangeFieldOptions) => FieldMapping;
|
|
44
|
-
export declare const doubleRange: (options?: RangeFieldOptions) => FieldMapping;
|
|
45
|
-
export declare const dateRange: (options?: RangeFieldOptions) => FieldMapping;
|
|
16
|
+
import type { TextFieldOptions, KeywordFieldOptions, NumericFieldOptions, ScaledFloatFieldOptions, DateFieldOptions, BooleanFieldOptions, DenseVectorFieldOptions, NestedFields, ObjectFieldOptions, CompletionFieldOptions, GeoPointFieldOptions, GeoShapeFieldOptions, AliasFieldOptions, IpFieldOptions, RangeFieldOptions, MatchOnlyTextFieldOptions, SearchAsYouTypeFieldOptions, ConstantKeywordFieldOptions, WildcardFieldOptions, FlattenedFieldOptions, 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, MatchOnlyTextFieldMapping, SearchAsYouTypeFieldMapping, ConstantKeywordFieldMapping, WildcardFieldMapping, FlattenedFieldMapping } from './field.types.js';
|
|
17
|
+
export declare const text: (options?: TextFieldOptions) => TextFieldMapping;
|
|
18
|
+
export declare const keyword: (options?: KeywordFieldOptions) => KeywordFieldMapping;
|
|
19
|
+
export declare const long: (options?: NumericFieldOptions) => LongFieldMapping;
|
|
20
|
+
export declare const integer: (options?: NumericFieldOptions) => IntegerFieldMapping;
|
|
21
|
+
export declare const short: (options?: NumericFieldOptions) => ShortFieldMapping;
|
|
22
|
+
export declare const byte: (options?: NumericFieldOptions) => ByteFieldMapping;
|
|
23
|
+
export declare const double: (options?: NumericFieldOptions) => DoubleFieldMapping;
|
|
24
|
+
export declare const float: (options?: NumericFieldOptions) => FloatFieldMapping;
|
|
25
|
+
export declare const halfFloat: (options?: NumericFieldOptions) => HalfFloatFieldMapping;
|
|
26
|
+
export declare const scaledFloat: (options?: ScaledFloatFieldOptions) => ScaledFloatFieldMapping;
|
|
27
|
+
export declare const date: (options?: DateFieldOptions) => DateFieldMapping;
|
|
28
|
+
export declare const boolean: (options?: BooleanFieldOptions) => BooleanFieldMapping;
|
|
29
|
+
export declare const binary: () => BinaryFieldMapping;
|
|
30
|
+
export declare const ip: (options?: IpFieldOptions) => IpFieldMapping;
|
|
31
|
+
export declare const denseVector: (options?: DenseVectorFieldOptions) => DenseVectorFieldMapping;
|
|
46
32
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
33
|
+
* Quantized dense vector field — wraps `denseVector()` with `int8_hnsw` index type.
|
|
34
|
+
*
|
|
35
|
+
* Quantizes float32 vectors to int8 at index time, saving ~75% memory.
|
|
36
|
+
* Recommended for vectors with dims >= 384. Original float vectors are retained
|
|
37
|
+
* in the index, enabling a two-phase search pattern:
|
|
38
|
+
*
|
|
39
|
+
* 1. Fast approximate search using quantized int8 vectors
|
|
40
|
+
* 2. Precise rescore of top-k results using retained float vectors
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Index mapping
|
|
44
|
+
* const schema = mappings({
|
|
45
|
+
* title: text(),
|
|
46
|
+
* embedding: quantizedDenseVector({ dims: 768, similarity: 'cosine' }),
|
|
47
|
+
* }, {
|
|
48
|
+
* _source: { excludes: ['embedding'] },
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // Two-phase search: fast kNN + precise rescore
|
|
52
|
+
* const result = query(schema)
|
|
53
|
+
* .knn('embedding', queryVector, { k: 100, num_candidates: 200 })
|
|
54
|
+
* .rescore(
|
|
55
|
+
* (q) => q.scriptScore(
|
|
56
|
+
* (inner) => inner.matchAll(),
|
|
57
|
+
* { source: "cosineSimilarity(params.v, 'embedding') + 1.0", params: { v: queryVector } }
|
|
58
|
+
* ),
|
|
59
|
+
* 100
|
|
60
|
+
* )
|
|
61
|
+
* .build();
|
|
62
|
+
*/
|
|
63
|
+
export declare const quantizedDenseVector: (options?: DenseVectorFieldOptions) => DenseVectorFieldMapping;
|
|
64
|
+
export declare const geoPoint: (options?: GeoPointFieldOptions) => GeoPointFieldMapping;
|
|
65
|
+
export declare const geoShape: (options?: GeoShapeFieldOptions) => GeoShapeFieldMapping;
|
|
66
|
+
export declare const completion: (options?: CompletionFieldOptions) => CompletionFieldMapping;
|
|
67
|
+
export declare const nested: (fields?: NestedFields) => NestedFieldMapping;
|
|
68
|
+
export declare const object: (fields?: NestedFields, options?: ObjectFieldOptions) => ObjectFieldMapping;
|
|
69
|
+
export declare const alias: (options: AliasFieldOptions) => AliasFieldMapping;
|
|
70
|
+
export declare const percolator: () => PercolatorFieldMapping;
|
|
71
|
+
export declare const integerRange: (options?: RangeFieldOptions) => IntegerRangeFieldMapping;
|
|
72
|
+
export declare const floatRange: (options?: RangeFieldOptions) => FloatRangeFieldMapping;
|
|
73
|
+
export declare const longRange: (options?: RangeFieldOptions) => LongRangeFieldMapping;
|
|
74
|
+
export declare const doubleRange: (options?: RangeFieldOptions) => DoubleRangeFieldMapping;
|
|
75
|
+
export declare const dateRange: (options?: RangeFieldOptions) => DateRangeFieldMapping;
|
|
76
|
+
/**
|
|
77
|
+
* No-score text field — faster and uses less disk than `text()`.
|
|
78
|
+
* Use when you only need filter/match but not relevance scoring (e.g., logs, simple field matches).
|
|
79
|
+
*/
|
|
80
|
+
export declare const matchOnlyText: (options?: MatchOnlyTextFieldOptions) => MatchOnlyTextFieldMapping;
|
|
81
|
+
/**
|
|
82
|
+
* Autocomplete / typeahead field. Creates sub-fields for edge n-gram matching
|
|
83
|
+
* out of the box. Query with `multi_match` targeting the generated sub-fields.
|
|
84
|
+
*/
|
|
85
|
+
export declare const searchAsYouType: (options?: SearchAsYouTypeFieldOptions) => SearchAsYouTypeFieldMapping;
|
|
86
|
+
/**
|
|
87
|
+
* Field where every document has the same value. Useful for multi-index queries
|
|
88
|
+
* to identify the index type (e.g., `constantKeyword({ value: 'product' })`).
|
|
89
|
+
*/
|
|
90
|
+
export declare const constantKeyword: (options?: ConstantKeywordFieldOptions) => ConstantKeywordFieldMapping;
|
|
91
|
+
/**
|
|
92
|
+
* Optimized for grep-like wildcard/regexp queries on high-cardinality or large fields.
|
|
93
|
+
* Use instead of `keyword()` when leading wildcards (`*foo`) are needed.
|
|
94
|
+
*/
|
|
95
|
+
export declare const wildcardField: (options?: WildcardFieldOptions) => WildcardFieldMapping;
|
|
96
|
+
/**
|
|
97
|
+
* Flattens complex/dynamic objects into a single field. Faster than `nested()`,
|
|
98
|
+
* but only supports keyword-level queries on inner values.
|
|
49
99
|
*/
|
|
50
|
-
export declare const
|
|
100
|
+
export declare const flattened: (options?: FlattenedFieldOptions) => FlattenedFieldMapping;
|
|
51
101
|
//# 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.helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,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AM,WAAW,GAAI,UAAU,iBAAiB,KAAG,uBAGxD,CAAC;AACH,eAAO,MAAM,SAAS,GAAI,UAAU,iBAAiB,KAAG,qBAGtD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,UAAU,yBAAyB,KAAG,yBAGlE,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,2BAA2B,KAAG,2BAGtE,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,2BAA2B,KAAG,2BAGtE,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,UAAU,oBAAoB,KAAG,oBAG7D,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,UAAU,qBAAqB,KAAG,qBAG1D,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) => ({
|
|
@@ -52,7 +51,10 @@ export const halfFloat = (options) => ({
|
|
|
52
51
|
type: 'half_float',
|
|
53
52
|
...options
|
|
54
53
|
});
|
|
55
|
-
export const scaledFloat = (options) => ({
|
|
54
|
+
export const scaledFloat = (options) => ({
|
|
55
|
+
type: 'scaled_float',
|
|
56
|
+
...options
|
|
57
|
+
});
|
|
56
58
|
// Date & boolean
|
|
57
59
|
export const date = (options) => ({
|
|
58
60
|
type: 'date',
|
|
@@ -63,6 +65,7 @@ export const boolean = (options) => ({
|
|
|
63
65
|
...options
|
|
64
66
|
});
|
|
65
67
|
// Binary
|
|
68
|
+
// eslint-disable-next-line functional/functional-parameters
|
|
66
69
|
export const binary = () => ({ type: 'binary' });
|
|
67
70
|
// IP
|
|
68
71
|
export const ip = (options) => ({
|
|
@@ -70,7 +73,46 @@ export const ip = (options) => ({
|
|
|
70
73
|
...options
|
|
71
74
|
});
|
|
72
75
|
// Vector
|
|
73
|
-
export const denseVector = (options) => ({
|
|
76
|
+
export const denseVector = (options) => ({
|
|
77
|
+
type: 'dense_vector',
|
|
78
|
+
...options
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* Quantized dense vector field — wraps `denseVector()` with `int8_hnsw` index type.
|
|
82
|
+
*
|
|
83
|
+
* Quantizes float32 vectors to int8 at index time, saving ~75% memory.
|
|
84
|
+
* Recommended for vectors with dims >= 384. Original float vectors are retained
|
|
85
|
+
* in the index, enabling a two-phase search pattern:
|
|
86
|
+
*
|
|
87
|
+
* 1. Fast approximate search using quantized int8 vectors
|
|
88
|
+
* 2. Precise rescore of top-k results using retained float vectors
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* // Index mapping
|
|
92
|
+
* const schema = mappings({
|
|
93
|
+
* title: text(),
|
|
94
|
+
* embedding: quantizedDenseVector({ dims: 768, similarity: 'cosine' }),
|
|
95
|
+
* }, {
|
|
96
|
+
* _source: { excludes: ['embedding'] },
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* // Two-phase search: fast kNN + precise rescore
|
|
100
|
+
* const result = query(schema)
|
|
101
|
+
* .knn('embedding', queryVector, { k: 100, num_candidates: 200 })
|
|
102
|
+
* .rescore(
|
|
103
|
+
* (q) => q.scriptScore(
|
|
104
|
+
* (inner) => inner.matchAll(),
|
|
105
|
+
* { source: "cosineSimilarity(params.v, 'embedding') + 1.0", params: { v: queryVector } }
|
|
106
|
+
* ),
|
|
107
|
+
* 100
|
|
108
|
+
* )
|
|
109
|
+
* .build();
|
|
110
|
+
*/
|
|
111
|
+
export const quantizedDenseVector = (options) => ({
|
|
112
|
+
type: 'dense_vector',
|
|
113
|
+
...options,
|
|
114
|
+
index_options: { type: 'int8_hnsw', ...options?.index_options }
|
|
115
|
+
});
|
|
74
116
|
// Geo
|
|
75
117
|
export const geoPoint = (options) => ({
|
|
76
118
|
type: 'geo_point',
|
|
@@ -88,12 +130,12 @@ export const completion = (options) => ({
|
|
|
88
130
|
// Structured
|
|
89
131
|
export const nested = (fields) => ({
|
|
90
132
|
type: 'nested',
|
|
91
|
-
...(fields && { properties:
|
|
133
|
+
...(fields && { properties: fields })
|
|
92
134
|
});
|
|
93
135
|
export const object = (fields, options) => ({
|
|
94
136
|
type: 'object',
|
|
95
|
-
...(options
|
|
96
|
-
...(fields && { properties:
|
|
137
|
+
...(options && options),
|
|
138
|
+
...(fields && { properties: fields })
|
|
97
139
|
});
|
|
98
140
|
// Alias
|
|
99
141
|
export const alias = (options) => ({
|
|
@@ -101,7 +143,10 @@ export const alias = (options) => ({
|
|
|
101
143
|
...options
|
|
102
144
|
});
|
|
103
145
|
// Percolator
|
|
104
|
-
|
|
146
|
+
// eslint-disable-next-line functional/functional-parameters
|
|
147
|
+
export const percolator = () => ({
|
|
148
|
+
type: 'percolator'
|
|
149
|
+
});
|
|
105
150
|
// Range types
|
|
106
151
|
export const integerRange = (options) => ({
|
|
107
152
|
type: 'integer_range',
|
|
@@ -124,8 +169,42 @@ export const dateRange = (options) => ({
|
|
|
124
169
|
...options
|
|
125
170
|
});
|
|
126
171
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
172
|
+
* No-score text field — faster and uses less disk than `text()`.
|
|
173
|
+
* Use when you only need filter/match but not relevance scoring (e.g., logs, simple field matches).
|
|
129
174
|
*/
|
|
130
|
-
export const
|
|
131
|
-
|
|
175
|
+
export const matchOnlyText = (options) => ({
|
|
176
|
+
type: 'match_only_text',
|
|
177
|
+
...options
|
|
178
|
+
});
|
|
179
|
+
/**
|
|
180
|
+
* Autocomplete / typeahead field. Creates sub-fields for edge n-gram matching
|
|
181
|
+
* out of the box. Query with `multi_match` targeting the generated sub-fields.
|
|
182
|
+
*/
|
|
183
|
+
export const searchAsYouType = (options) => ({
|
|
184
|
+
type: 'search_as_you_type',
|
|
185
|
+
...options
|
|
186
|
+
});
|
|
187
|
+
/**
|
|
188
|
+
* Field where every document has the same value. Useful for multi-index queries
|
|
189
|
+
* to identify the index type (e.g., `constantKeyword({ value: 'product' })`).
|
|
190
|
+
*/
|
|
191
|
+
export const constantKeyword = (options) => ({
|
|
192
|
+
type: 'constant_keyword',
|
|
193
|
+
...options
|
|
194
|
+
});
|
|
195
|
+
/**
|
|
196
|
+
* Optimized for grep-like wildcard/regexp queries on high-cardinality or large fields.
|
|
197
|
+
* Use instead of `keyword()` when leading wildcards (`*foo`) are needed.
|
|
198
|
+
*/
|
|
199
|
+
export const wildcardField = (options) => ({
|
|
200
|
+
type: 'wildcard',
|
|
201
|
+
...options
|
|
202
|
+
});
|
|
203
|
+
/**
|
|
204
|
+
* Flattens complex/dynamic objects into a single field. Faster than `nested()`,
|
|
205
|
+
* but only supports keyword-level queries on inner values.
|
|
206
|
+
*/
|
|
207
|
+
export const flattened = (options) => ({
|
|
208
|
+
type: 'flattened',
|
|
209
|
+
...options
|
|
210
|
+
});
|
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;
|
|
@@ -14,6 +14,14 @@ export type TextFieldOptions = {
|
|
|
14
14
|
doc_values?: boolean;
|
|
15
15
|
similarity?: string;
|
|
16
16
|
fields?: Record<string, FieldMapping>;
|
|
17
|
+
copy_to?: string | string[];
|
|
18
|
+
index_prefixes?: {
|
|
19
|
+
min_chars?: number;
|
|
20
|
+
max_chars?: number;
|
|
21
|
+
};
|
|
22
|
+
index_phrases?: boolean;
|
|
23
|
+
eager_global_ordinals?: boolean;
|
|
24
|
+
term_vector?: 'no' | 'yes' | 'with_positions' | 'with_offsets' | 'with_positions_offsets' | 'with_positions_payloads' | 'with_positions_offsets_payloads';
|
|
17
25
|
};
|
|
18
26
|
/** Options for keyword fields */
|
|
19
27
|
export type KeywordFieldOptions = {
|
|
@@ -24,6 +32,10 @@ export type KeywordFieldOptions = {
|
|
|
24
32
|
similarity?: string;
|
|
25
33
|
normalizer?: string;
|
|
26
34
|
fields?: Record<string, FieldMapping>;
|
|
35
|
+
copy_to?: string | string[];
|
|
36
|
+
null_value?: string;
|
|
37
|
+
eager_global_ordinals?: boolean;
|
|
38
|
+
ignore_above?: number;
|
|
27
39
|
};
|
|
28
40
|
/** Options shared by numeric field types (long, integer, short, byte, double, float, half_float) */
|
|
29
41
|
export type NumericFieldOptions = {
|
|
@@ -33,6 +45,9 @@ export type NumericFieldOptions = {
|
|
|
33
45
|
doc_values?: boolean;
|
|
34
46
|
coerce?: boolean;
|
|
35
47
|
fields?: Record<string, FieldMapping>;
|
|
48
|
+
copy_to?: string | string[];
|
|
49
|
+
null_value?: number;
|
|
50
|
+
ignore_malformed?: boolean;
|
|
36
51
|
};
|
|
37
52
|
/** Options for scaled_float (extends numeric with scaling_factor) */
|
|
38
53
|
export type ScaledFloatFieldOptions = NumericFieldOptions & {
|
|
@@ -46,6 +61,9 @@ export type DateFieldOptions = {
|
|
|
46
61
|
store?: boolean;
|
|
47
62
|
doc_values?: boolean;
|
|
48
63
|
fields?: Record<string, FieldMapping>;
|
|
64
|
+
copy_to?: string | string[];
|
|
65
|
+
null_value?: string;
|
|
66
|
+
ignore_malformed?: boolean;
|
|
49
67
|
};
|
|
50
68
|
/** Options for boolean fields */
|
|
51
69
|
export type BooleanFieldOptions = {
|
|
@@ -53,6 +71,7 @@ export type BooleanFieldOptions = {
|
|
|
53
71
|
index?: boolean;
|
|
54
72
|
store?: boolean;
|
|
55
73
|
doc_values?: boolean;
|
|
74
|
+
null_value?: boolean;
|
|
56
75
|
};
|
|
57
76
|
/** Options for dense_vector fields */
|
|
58
77
|
export type DenseVectorFieldOptions = {
|
|
@@ -63,7 +82,7 @@ export type DenseVectorFieldOptions = {
|
|
|
63
82
|
similarity?: 'cosine' | 'dot_product' | 'l2_norm' | 'max_inner_product';
|
|
64
83
|
};
|
|
65
84
|
/** Sub-fields for nested and object field types */
|
|
66
|
-
export type NestedFields = Record<string,
|
|
85
|
+
export type NestedFields = Record<string, FieldMapping>;
|
|
67
86
|
/** Options for object fields (enabled flag only — sub-fields are the first argument) */
|
|
68
87
|
export type ObjectFieldOptions = {
|
|
69
88
|
enabled?: boolean;
|
|
@@ -81,6 +100,7 @@ export type GeoPointFieldOptions = {
|
|
|
81
100
|
index?: boolean;
|
|
82
101
|
store?: boolean;
|
|
83
102
|
doc_values?: boolean;
|
|
103
|
+
ignore_malformed?: boolean;
|
|
84
104
|
};
|
|
85
105
|
/** Options for geo_shape fields */
|
|
86
106
|
export type GeoShapeFieldOptions = {
|
|
@@ -92,7 +112,7 @@ export type GeoShapeFieldOptions = {
|
|
|
92
112
|
};
|
|
93
113
|
/** Options for alias fields */
|
|
94
114
|
export type AliasFieldOptions = {
|
|
95
|
-
path
|
|
115
|
+
path: string;
|
|
96
116
|
};
|
|
97
117
|
/** Options for ip fields */
|
|
98
118
|
export type IpFieldOptions = {
|
|
@@ -100,6 +120,8 @@ export type IpFieldOptions = {
|
|
|
100
120
|
index?: boolean;
|
|
101
121
|
store?: boolean;
|
|
102
122
|
doc_values?: boolean;
|
|
123
|
+
null_value?: string;
|
|
124
|
+
ignore_malformed?: boolean;
|
|
103
125
|
};
|
|
104
126
|
/** Options for range fields (integer_range, float_range, long_range, double_range, date_range) */
|
|
105
127
|
export type RangeFieldOptions = {
|
|
@@ -109,4 +131,89 @@ export type RangeFieldOptions = {
|
|
|
109
131
|
doc_values?: boolean;
|
|
110
132
|
coerce?: boolean;
|
|
111
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* Options for match_only_text fields.
|
|
136
|
+
* Use when you only need filter/match but not relevance scoring — faster and uses less disk.
|
|
137
|
+
*/
|
|
138
|
+
export type MatchOnlyTextFieldOptions = {
|
|
139
|
+
fields?: Record<string, FieldMapping>;
|
|
140
|
+
copy_to?: string | string[];
|
|
141
|
+
meta?: Record<string, string>;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Options for search_as_you_type fields.
|
|
145
|
+
* Provides out-of-the-box autocomplete / typeahead capabilities.
|
|
146
|
+
*/
|
|
147
|
+
export type SearchAsYouTypeFieldOptions = {
|
|
148
|
+
analyzer?: string;
|
|
149
|
+
search_analyzer?: string;
|
|
150
|
+
max_shingle_size?: number;
|
|
151
|
+
index?: boolean;
|
|
152
|
+
similarity?: string;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Options for constant_keyword fields.
|
|
156
|
+
* Every document in the index has the same value for this field.
|
|
157
|
+
* Useful for multi-index queries to identify the index type.
|
|
158
|
+
*/
|
|
159
|
+
export type ConstantKeywordFieldOptions = {
|
|
160
|
+
value?: string;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Options for wildcard fields.
|
|
164
|
+
* Optimized for grep-like wildcard/regexp queries on high-cardinality or large fields.
|
|
165
|
+
* Use instead of keyword when leading wildcards (`*foo`) are needed.
|
|
166
|
+
*/
|
|
167
|
+
export type WildcardFieldOptions = {
|
|
168
|
+
null_value?: string;
|
|
169
|
+
ignore_above?: number;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Options for flattened fields.
|
|
173
|
+
* Flattens complex/dynamic objects into a single field. Faster than nested,
|
|
174
|
+
* but only supports keyword-level queries on inner values.
|
|
175
|
+
*/
|
|
176
|
+
export type FlattenedFieldOptions = {
|
|
177
|
+
depth_limit?: number;
|
|
178
|
+
doc_values?: boolean;
|
|
179
|
+
index?: boolean;
|
|
180
|
+
null_value?: string;
|
|
181
|
+
similarity?: string;
|
|
182
|
+
eager_global_ordinals?: boolean;
|
|
183
|
+
};
|
|
184
|
+
export type TypedFieldMapping<T extends string> = Omit<FieldMapping, 'type'> & {
|
|
185
|
+
type: T;
|
|
186
|
+
};
|
|
187
|
+
export type TextFieldMapping = TypedFieldMapping<'text'>;
|
|
188
|
+
export type KeywordFieldMapping = TypedFieldMapping<'keyword'>;
|
|
189
|
+
export type LongFieldMapping = TypedFieldMapping<'long'>;
|
|
190
|
+
export type IntegerFieldMapping = TypedFieldMapping<'integer'>;
|
|
191
|
+
export type ShortFieldMapping = TypedFieldMapping<'short'>;
|
|
192
|
+
export type ByteFieldMapping = TypedFieldMapping<'byte'>;
|
|
193
|
+
export type DoubleFieldMapping = TypedFieldMapping<'double'>;
|
|
194
|
+
export type FloatFieldMapping = TypedFieldMapping<'float'>;
|
|
195
|
+
export type HalfFloatFieldMapping = TypedFieldMapping<'half_float'>;
|
|
196
|
+
export type ScaledFloatFieldMapping = TypedFieldMapping<'scaled_float'>;
|
|
197
|
+
export type DateFieldMapping = TypedFieldMapping<'date'>;
|
|
198
|
+
export type BooleanFieldMapping = TypedFieldMapping<'boolean'>;
|
|
199
|
+
export type BinaryFieldMapping = TypedFieldMapping<'binary'>;
|
|
200
|
+
export type IpFieldMapping = TypedFieldMapping<'ip'>;
|
|
201
|
+
export type DenseVectorFieldMapping = TypedFieldMapping<'dense_vector'>;
|
|
202
|
+
export type GeoPointFieldMapping = TypedFieldMapping<'geo_point'>;
|
|
203
|
+
export type GeoShapeFieldMapping = TypedFieldMapping<'geo_shape'>;
|
|
204
|
+
export type CompletionFieldMapping = TypedFieldMapping<'completion'>;
|
|
205
|
+
export type NestedFieldMapping = TypedFieldMapping<'nested'>;
|
|
206
|
+
export type ObjectFieldMapping = TypedFieldMapping<'object'>;
|
|
207
|
+
export type AliasFieldMapping = TypedFieldMapping<'alias'>;
|
|
208
|
+
export type PercolatorFieldMapping = TypedFieldMapping<'percolator'>;
|
|
209
|
+
export type IntegerRangeFieldMapping = TypedFieldMapping<'integer_range'>;
|
|
210
|
+
export type FloatRangeFieldMapping = TypedFieldMapping<'float_range'>;
|
|
211
|
+
export type LongRangeFieldMapping = TypedFieldMapping<'long_range'>;
|
|
212
|
+
export type DoubleRangeFieldMapping = TypedFieldMapping<'double_range'>;
|
|
213
|
+
export type DateRangeFieldMapping = TypedFieldMapping<'date_range'>;
|
|
214
|
+
export type MatchOnlyTextFieldMapping = TypedFieldMapping<'match_only_text'>;
|
|
215
|
+
export type SearchAsYouTypeFieldMapping = TypedFieldMapping<'search_as_you_type'>;
|
|
216
|
+
export type ConstantKeywordFieldMapping = TypedFieldMapping<'constant_keyword'>;
|
|
217
|
+
export type WildcardFieldMapping = TypedFieldMapping<'wildcard'>;
|
|
218
|
+
export type FlattenedFieldMapping = TypedFieldMapping<'flattened'>;
|
|
112
219
|
//# 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":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AA2B,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;AAChF,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;AACjE,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,WAAW,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,27 @@ 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
|
-
* Create a new index builder
|
|
12
|
+
* Create a new index builder for Elasticsearch index configuration.
|
|
13
|
+
*
|
|
14
|
+
* Typical lifecycle:
|
|
15
|
+
* 1. **Create index:** `indexBuilder().mappings(schema).settings(productionSearchSettings()).build()`
|
|
16
|
+
* 2. **Bulk ingest:** Apply `fastIngestSettings()` via ES `_settings` API → bulk index →
|
|
17
|
+
* apply `productionSearchSettings()` → `POST /index/_refresh`
|
|
18
|
+
* 3. **Normal operations:** Query, update individual docs via `_update` API
|
|
19
|
+
* 4. **Migration with mapping changes:** Create new index with new mappings → `POST _reindex`
|
|
20
|
+
* from old → atomically swap alias via `POST _aliases` → delete old index
|
|
21
|
+
*
|
|
22
|
+
* After bulk loading, remember to refresh the index with `POST /index/_refresh`
|
|
23
|
+
* to make all documents searchable.
|
|
24
|
+
*
|
|
13
25
|
* @example
|
|
14
|
-
* const indexConfig = indexBuilder
|
|
15
|
-
* .mappings(
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* category: 'keyword',
|
|
19
|
-
* })
|
|
20
|
-
* .settings({
|
|
21
|
-
* number_of_shards: 1,
|
|
22
|
-
* number_of_replicas: 1
|
|
23
|
-
* })
|
|
24
|
-
* .alias('products_alias')
|
|
26
|
+
* const indexConfig = indexBuilder()
|
|
27
|
+
* .mappings(productMappings)
|
|
28
|
+
* .settings(productionSearchSettings())
|
|
29
|
+
* .alias('products')
|
|
25
30
|
* .build();
|
|
26
31
|
*/
|
|
27
|
-
export declare const indexBuilder:
|
|
32
|
+
export declare const indexBuilder: () => IndexBuilder;
|
|
28
33
|
//# 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,EAAiC,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAOnH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAO,kBAAuB,KAAG,YAiClE,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,eAAO,MAAM,YAAY,oBAA6B,CAAC"}
|