elasticlink 0.3.0-beta → 0.4.1-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 +61 -14
- package/dist/aggregation.builder.d.ts.map +1 -1
- package/dist/aggregation.builder.js +101 -94
- package/dist/aggregation.types.d.ts +10 -9
- package/dist/aggregation.types.d.ts.map +1 -1
- package/dist/bulk.builder.d.ts +11 -1
- package/dist/bulk.builder.d.ts.map +1 -1
- package/dist/bulk.builder.js +10 -11
- package/dist/bulk.types.d.ts.map +1 -1
- package/dist/field.helpers.d.ts +59 -4
- package/dist/field.helpers.d.ts.map +1 -1
- package/dist/field.helpers.js +87 -4
- package/dist/field.types.d.ts +78 -1
- package/dist/field.types.d.ts.map +1 -1
- package/dist/index-management.builder.d.ts +15 -3
- package/dist/index-management.builder.d.ts.map +1 -1
- package/dist/index-management.builder.js +32 -8
- package/dist/index-management.types.d.ts +27 -3
- package/dist/index-management.types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/mapping.builder.d.ts +16 -3
- package/dist/mapping.builder.d.ts.map +1 -1
- package/dist/mapping.builder.js +22 -7
- package/dist/mapping.types.d.ts +29 -6
- package/dist/mapping.types.d.ts.map +1 -1
- package/dist/multi-search.builder.d.ts +1 -1
- package/dist/multi-search.builder.d.ts.map +1 -1
- package/dist/multi-search.builder.js +5 -3
- package/dist/query.builder.d.ts +0 -4
- package/dist/query.builder.d.ts.map +1 -1
- package/dist/query.builder.js +104 -183
- package/dist/query.types.d.ts +59 -5
- package/dist/query.types.d.ts.map +1 -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.map +1 -1
- package/dist/suggester.builder.js +1 -0
- package/dist/suggester.types.d.ts.map +1 -1
- package/dist/vector.types.d.ts.map +1 -1
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ elasticlink simplifies building Elasticsearch queries and index management in Ty
|
|
|
24
24
|
|
|
25
25
|
| elasticlink | Node.js | Elasticsearch |
|
|
26
26
|
|-------------|-------------|---------------|
|
|
27
|
+
| 0.4.0-beta | 20, 22, 24 | 9.x (≥9.0.0) |
|
|
27
28
|
| 0.3.0-beta | 20, 22, 24 | 9.x (≥9.0.0) |
|
|
28
29
|
| 0.2.0-beta | 20, 22 | 9.x (≥9.0.0) |
|
|
29
30
|
| 0.1.0-beta | 20, 22 | 9.x (≥9.0.0) |
|
|
@@ -76,7 +77,12 @@ const response = await client.search({ index: 'products', ...q });
|
|
|
76
77
|
- `match(field, value, options?)` - Full-text search
|
|
77
78
|
- `multiMatch(fields, query, options?)` - Search multiple fields
|
|
78
79
|
- `matchPhrase(field, query)` - Exact phrase matching
|
|
79
|
-
- `matchPhrasePrefix(field, query, options?)` - Prefix phrase matching
|
|
80
|
+
- `matchPhrasePrefix(field, query, options?)` - Prefix phrase matching
|
|
81
|
+
- `matchBoolPrefix(field, value, options?)` - Analyze and build a bool query from query terms, with the last term as a prefix (search-as-you-type)
|
|
82
|
+
- `combinedFields(fields, query, options?)` - Search across multiple fields treating them as one combined field
|
|
83
|
+
- `queryString(query, options?)` - Lucene query string syntax
|
|
84
|
+
- `simpleQueryString(query, options?)` - Simplified query string syntax with limited operators
|
|
85
|
+
- `moreLikeThis(fields, like, options?)` - Find documents similar to a given document or text
|
|
80
86
|
- `term(field, value)` - Exact term matching
|
|
81
87
|
- `terms(field, values)` - Multiple exact values
|
|
82
88
|
- `range(field, conditions)` - Range queries (gte, lte, gt, lt)
|
|
@@ -212,8 +218,6 @@ const standaloneAgg = aggregations(productMappings)
|
|
|
212
218
|
|
|
213
219
|
### Vector Search & Semantic Search
|
|
214
220
|
|
|
215
|
-
**Requires Elasticsearch 8.0+**
|
|
216
|
-
|
|
217
221
|
KNN (k-nearest neighbors) queries enable semantic search using vector embeddings from machine learning models.
|
|
218
222
|
|
|
219
223
|
```typescript
|
|
@@ -348,6 +352,8 @@ const customScored = query(scoredProductMappings)
|
|
|
348
352
|
Percolate queries enable reverse search - match documents against stored queries. Perfect for alerting, content classification, and saved searches.
|
|
349
353
|
|
|
350
354
|
```typescript
|
|
355
|
+
import { query, mappings, keyword, percolator } from 'elasticlink';
|
|
356
|
+
|
|
351
357
|
const alertRuleMappings = mappings({
|
|
352
358
|
query: percolator(),
|
|
353
359
|
name: keyword(),
|
|
@@ -612,17 +618,18 @@ denseVector({ dims: 384, index: true, similarity: 'cosine' })
|
|
|
612
618
|
|
|
613
619
|
#### Field Types (25+ supported)
|
|
614
620
|
|
|
615
|
-
| Category | Helpers
|
|
616
|
-
| ----------- |
|
|
617
|
-
| Text | `text`, `keyword`, `constantKeyword`
|
|
618
|
-
| Numeric | `long`, `integer`, `short`, `byte`, `double`, `float`, `halfFloat`, `scaledFloat`
|
|
619
|
-
| Date | `date
|
|
620
|
-
| Boolean | `boolean`
|
|
621
|
-
| Range | `integerRange`, `floatRange`, `longRange`, `doubleRange`, `dateRange`
|
|
622
|
-
| Objects | `object`, `nested`, `flattened`
|
|
623
|
-
| Spatial | `geoPoint`, `geoShape`
|
|
624
|
-
|
|
|
625
|
-
|
|
|
621
|
+
| Category | Helpers |
|
|
622
|
+
| ----------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
623
|
+
| Text | `text`, `keyword`, `constantKeyword`, `matchOnlyText`, `searchAsYouType`, `wildcardField` |
|
|
624
|
+
| Numeric | `long`, `integer`, `short`, `byte`, `double`, `float`, `halfFloat`, `scaledFloat` |
|
|
625
|
+
| Date | `date` |
|
|
626
|
+
| Boolean | `boolean` |
|
|
627
|
+
| Range | `integerRange`, `floatRange`, `longRange`, `doubleRange`, `dateRange` |
|
|
628
|
+
| Objects | `object`, `nested`, `flattened` |
|
|
629
|
+
| Spatial | `geoPoint`, `geoShape` |
|
|
630
|
+
| Vector | `denseVector`, `quantizedDenseVector` |
|
|
631
|
+
| Specialized | `ip`, `binary`, `completion`, `percolator` |
|
|
632
|
+
| Alias | `alias` |
|
|
626
633
|
|
|
627
634
|
#### Mapping Properties
|
|
628
635
|
|
|
@@ -678,6 +685,46 @@ The `.alias()` method accepts an optional `IndicesAlias` object:
|
|
|
678
685
|
| `search_routing` | `string` | Routing value for search operations only |
|
|
679
686
|
| `is_hidden` | `boolean` | Hide alias from wildcard expressions |
|
|
680
687
|
|
|
688
|
+
### Settings Presets
|
|
689
|
+
|
|
690
|
+
Ready-made index settings for common lifecycle stages. Use with `.settings()` on `indexBuilder()` or pass directly to the ES `_settings` API.
|
|
691
|
+
|
|
692
|
+
```typescript
|
|
693
|
+
import { productionSearchSettings, indexSortSettings, fastIngestSettings } from 'elasticlink';
|
|
694
|
+
|
|
695
|
+
// Create index with production settings
|
|
696
|
+
const indexConfig = indexBuilder()
|
|
697
|
+
.mappings(myMappings)
|
|
698
|
+
.settings(productionSearchSettings())
|
|
699
|
+
.build();
|
|
700
|
+
|
|
701
|
+
// Index-time sort for compression and early termination
|
|
702
|
+
const sortedConfig = indexBuilder()
|
|
703
|
+
.mappings(myMappings)
|
|
704
|
+
.settings({
|
|
705
|
+
...productionSearchSettings(),
|
|
706
|
+
index: indexSortSettings({ timestamp: 'desc', status: 'asc' })
|
|
707
|
+
})
|
|
708
|
+
.build();
|
|
709
|
+
|
|
710
|
+
// Before bulk ingest — disables refresh, removes replicas, async translog
|
|
711
|
+
await client.indices.putSettings({ index: 'my-index', body: fastIngestSettings() });
|
|
712
|
+
|
|
713
|
+
// Perform bulk ingest...
|
|
714
|
+
|
|
715
|
+
// Restore production settings afterward
|
|
716
|
+
await client.indices.putSettings({ index: 'my-index', body: productionSearchSettings() });
|
|
717
|
+
await client.indices.refresh({ index: 'my-index' });
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
| Preset | Purpose |
|
|
721
|
+
| ------ | ------- |
|
|
722
|
+
| `productionSearchSettings(overrides?)` | Balanced production defaults — 1 replica, 5s refresh |
|
|
723
|
+
| `indexSortSettings(fields)` | Configure index-time sort order for disk compression and early termination |
|
|
724
|
+
| `fastIngestSettings(overrides?)` | Maximum indexing throughput — async translog, no replicas, refresh disabled |
|
|
725
|
+
|
|
726
|
+
`fastIngestSettings` deep-merges the `translog` key so individual translog overrides don't clobber the other defaults. All presets accept an optional `overrides` argument typed as `Partial<IndicesIndexSettings>`.
|
|
727
|
+
|
|
681
728
|
## Examples
|
|
682
729
|
|
|
683
730
|
More examples available in [src/\_\_tests\_\_/examples.test.ts](src/__tests__/examples.test.ts).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregation.builder.d.ts","sourceRoot":"","sources":["../src/aggregation.builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAajB,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,wBAAwB,
|
|
1
|
+
{"version":3,"file":"aggregation.builder.d.ts","sourceRoot":"","sources":["../src/aggregation.builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAajB,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAChF,QAAO,gBAAqB,KAC3B,kBAAkB,CAAC,CAAC,CAsKrB,CAAC;AAGH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,SAAS,cAAc,CAAC,CAAC,CAAC,0BACnE,CAAC"}
|
|
@@ -1,147 +1,154 @@
|
|
|
1
1
|
export const createAggregationBuilder = (state = {}) => ({
|
|
2
2
|
// Bucket aggregations
|
|
3
3
|
terms: (name, field, options) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
return createAggregationBuilder({
|
|
5
|
+
...state,
|
|
6
|
+
[name]: {
|
|
7
|
+
terms: {
|
|
8
|
+
field,
|
|
9
|
+
...(options && options)
|
|
10
|
+
}
|
|
9
11
|
}
|
|
10
|
-
};
|
|
11
|
-
return createAggregationBuilder(aggregations);
|
|
12
|
+
});
|
|
12
13
|
},
|
|
13
14
|
dateHistogram: (name, field, options) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
return createAggregationBuilder({
|
|
16
|
+
...state,
|
|
17
|
+
[name]: {
|
|
18
|
+
date_histogram: {
|
|
19
|
+
field,
|
|
20
|
+
...(options && options)
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
|
-
};
|
|
21
|
-
return createAggregationBuilder(aggregations);
|
|
23
|
+
});
|
|
22
24
|
},
|
|
23
25
|
range: (name, field, options) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
return createAggregationBuilder({
|
|
27
|
+
...state,
|
|
28
|
+
[name]: {
|
|
29
|
+
range: {
|
|
30
|
+
field,
|
|
31
|
+
...(options && options)
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
|
-
};
|
|
31
|
-
return createAggregationBuilder(aggregations);
|
|
34
|
+
});
|
|
32
35
|
},
|
|
33
36
|
histogram: (name, field, options) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
return createAggregationBuilder({
|
|
38
|
+
...state,
|
|
39
|
+
[name]: {
|
|
40
|
+
histogram: {
|
|
41
|
+
field,
|
|
42
|
+
...(options && options)
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
|
-
};
|
|
41
|
-
return createAggregationBuilder(aggregations);
|
|
45
|
+
});
|
|
42
46
|
},
|
|
43
47
|
// Metric aggregations
|
|
44
48
|
avg: (name, field, options) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
return createAggregationBuilder({
|
|
50
|
+
...state,
|
|
51
|
+
[name]: {
|
|
52
|
+
avg: {
|
|
53
|
+
field,
|
|
54
|
+
...(options && options)
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
|
-
};
|
|
52
|
-
return createAggregationBuilder(aggregations);
|
|
57
|
+
});
|
|
53
58
|
},
|
|
54
59
|
sum: (name, field, options) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
return createAggregationBuilder({
|
|
61
|
+
...state,
|
|
62
|
+
[name]: {
|
|
63
|
+
sum: {
|
|
64
|
+
field,
|
|
65
|
+
...(options && options)
|
|
66
|
+
}
|
|
60
67
|
}
|
|
61
|
-
};
|
|
62
|
-
return createAggregationBuilder(aggregations);
|
|
68
|
+
});
|
|
63
69
|
},
|
|
64
70
|
min: (name, field, options) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
return createAggregationBuilder({
|
|
72
|
+
...state,
|
|
73
|
+
[name]: {
|
|
74
|
+
min: {
|
|
75
|
+
field,
|
|
76
|
+
...(options && options)
|
|
77
|
+
}
|
|
70
78
|
}
|
|
71
|
-
};
|
|
72
|
-
return createAggregationBuilder(aggregations);
|
|
79
|
+
});
|
|
73
80
|
},
|
|
74
81
|
max: (name, field, options) => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
return createAggregationBuilder({
|
|
83
|
+
...state,
|
|
84
|
+
[name]: {
|
|
85
|
+
max: {
|
|
86
|
+
field,
|
|
87
|
+
...(options && options)
|
|
88
|
+
}
|
|
80
89
|
}
|
|
81
|
-
};
|
|
82
|
-
return createAggregationBuilder(aggregations);
|
|
90
|
+
});
|
|
83
91
|
},
|
|
84
92
|
cardinality: (name, field, options) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
return createAggregationBuilder({
|
|
94
|
+
...state,
|
|
95
|
+
[name]: {
|
|
96
|
+
cardinality: {
|
|
97
|
+
field,
|
|
98
|
+
...(options && options)
|
|
99
|
+
}
|
|
90
100
|
}
|
|
91
|
-
};
|
|
92
|
-
return createAggregationBuilder(aggregations);
|
|
101
|
+
});
|
|
93
102
|
},
|
|
94
103
|
percentiles: (name, field, options) => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
return createAggregationBuilder({
|
|
105
|
+
...state,
|
|
106
|
+
[name]: {
|
|
107
|
+
percentiles: {
|
|
108
|
+
field,
|
|
109
|
+
...(options && options)
|
|
110
|
+
}
|
|
100
111
|
}
|
|
101
|
-
};
|
|
102
|
-
return createAggregationBuilder(aggregations);
|
|
112
|
+
});
|
|
103
113
|
},
|
|
104
114
|
stats: (name, field, options) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
return createAggregationBuilder({
|
|
116
|
+
...state,
|
|
117
|
+
[name]: {
|
|
118
|
+
stats: {
|
|
119
|
+
field,
|
|
120
|
+
...(options && options)
|
|
121
|
+
}
|
|
110
122
|
}
|
|
111
|
-
};
|
|
112
|
-
return createAggregationBuilder(aggregations);
|
|
123
|
+
});
|
|
113
124
|
},
|
|
114
125
|
valueCount: (name, field, options) => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
return createAggregationBuilder({
|
|
127
|
+
...state,
|
|
128
|
+
[name]: {
|
|
129
|
+
value_count: {
|
|
130
|
+
field,
|
|
131
|
+
...(options && options)
|
|
132
|
+
}
|
|
120
133
|
}
|
|
121
|
-
};
|
|
122
|
-
return createAggregationBuilder(aggregations);
|
|
134
|
+
});
|
|
123
135
|
},
|
|
124
136
|
// Sub-aggregations
|
|
125
137
|
subAgg: (fn) => {
|
|
126
|
-
// Get the last aggregation added
|
|
127
138
|
const keys = Object.keys(state);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
const lastKey = keys[keys.length - 1];
|
|
132
|
-
const lastAgg = state[lastKey];
|
|
133
|
-
// Apply sub-aggregations
|
|
139
|
+
const lastKey = keys.at(-1);
|
|
140
|
+
const { [lastKey]: lastAgg } = state;
|
|
134
141
|
const subAggs = fn(createAggregationBuilder({})).build();
|
|
135
|
-
|
|
142
|
+
return createAggregationBuilder({
|
|
136
143
|
...state,
|
|
137
144
|
[lastKey]: {
|
|
138
145
|
...lastAgg,
|
|
139
146
|
aggs: subAggs
|
|
140
147
|
}
|
|
141
|
-
};
|
|
142
|
-
return createAggregationBuilder(updatedState);
|
|
148
|
+
});
|
|
143
149
|
},
|
|
144
150
|
// Build
|
|
151
|
+
// eslint-disable-next-line functional/functional-parameters
|
|
145
152
|
build: () => state
|
|
146
153
|
});
|
|
147
154
|
// Helper function to create aggregations without needing to import the builder
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { AggregationsTermsAggregation, AggregationsDateHistogramAggregation, AggregationsRangeAggregation, AggregationsHistogramAggregation, AggregationsAverageAggregation, AggregationsSumAggregation, AggregationsMinAggregation, AggregationsMaxAggregation, AggregationsCardinalityAggregation, AggregationsPercentilesAggregation, AggregationsStatsAggregation, AggregationsValueCountAggregation, AggregationsCalendarInterval } from '@elastic/elasticsearch/lib/api/types';
|
|
7
7
|
import type { FieldTypeString } from './index-management.types.js';
|
|
8
|
+
import type { DateFields, NumericFields } from './mapping.types.js';
|
|
8
9
|
/**
|
|
9
10
|
* Options for terms aggregation (excludes 'field' which is handled by the builder)
|
|
10
11
|
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
|
|
@@ -83,25 +84,25 @@ export type AggregationBuilder<M extends Record<string, FieldTypeString>> = {
|
|
|
83
84
|
/** Terms aggregation - group by field values */
|
|
84
85
|
terms: <K extends string & keyof M>(name: string, field: K, options?: TermsAggOptions) => AggregationBuilder<M>;
|
|
85
86
|
/** Date histogram aggregation - group by time intervals */
|
|
86
|
-
dateHistogram: <K extends
|
|
87
|
+
dateHistogram: <K extends DateFields<M> & string>(name: string, field: K, options?: DateHistogramAggOptions) => AggregationBuilder<M>;
|
|
87
88
|
/** Range aggregation - group by numeric/date ranges */
|
|
88
|
-
range: <K extends string & keyof M>(name: string, field: K, options
|
|
89
|
+
range: <K extends string & keyof M>(name: string, field: K, options?: RangeAggOptions) => AggregationBuilder<M>;
|
|
89
90
|
/** Histogram aggregation - group by numeric intervals */
|
|
90
|
-
histogram: <K extends
|
|
91
|
+
histogram: <K extends NumericFields<M> & string>(name: string, field: K, options?: HistogramAggOptions) => AggregationBuilder<M>;
|
|
91
92
|
/** Average aggregation */
|
|
92
|
-
avg: <K extends
|
|
93
|
+
avg: <K extends NumericFields<M> & string>(name: string, field: K, options?: AvgAggOptions) => AggregationBuilder<M>;
|
|
93
94
|
/** Sum aggregation */
|
|
94
|
-
sum: <K extends
|
|
95
|
+
sum: <K extends NumericFields<M> & string>(name: string, field: K, options?: SumAggOptions) => AggregationBuilder<M>;
|
|
95
96
|
/** Minimum value aggregation */
|
|
96
|
-
min: <K extends
|
|
97
|
+
min: <K extends NumericFields<M> & string>(name: string, field: K, options?: MinAggOptions) => AggregationBuilder<M>;
|
|
97
98
|
/** Maximum value aggregation */
|
|
98
|
-
max: <K extends
|
|
99
|
+
max: <K extends NumericFields<M> & string>(name: string, field: K, options?: MaxAggOptions) => AggregationBuilder<M>;
|
|
99
100
|
/** Cardinality aggregation - count unique values */
|
|
100
101
|
cardinality: <K extends string & keyof M>(name: string, field: K, options?: CardinalityAggOptions) => AggregationBuilder<M>;
|
|
101
102
|
/** Percentiles aggregation */
|
|
102
|
-
percentiles: <K extends
|
|
103
|
+
percentiles: <K extends NumericFields<M> & string>(name: string, field: K, options?: PercentilesAggOptions) => AggregationBuilder<M>;
|
|
103
104
|
/** Statistics aggregation (count, min, max, avg, sum) */
|
|
104
|
-
stats: <K extends
|
|
105
|
+
stats: <K extends NumericFields<M> & string>(name: string, field: K, options?: StatsAggOptions) => AggregationBuilder<M>;
|
|
105
106
|
/** Value count aggregation */
|
|
106
107
|
valueCount: <K extends string & keyof M>(name: string, field: K, options?: ValueCountAggOptions) => AggregationBuilder<M>;
|
|
107
108
|
/** Add sub-aggregation to parent bucket aggregation */
|
|
@@ -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;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,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,eAA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,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,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAE7F,4BAA4B;IAC5B,KAAK,EAAE,MAAM,gBAAgB,CAAC;CAC/B,CAAC"}
|
package/dist/bulk.builder.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const createBulkBuilder: <T>(operations?: any[]) => BulkBuilder<T
|
|
|
15
15
|
* `.build()` returns an NDJSON string (newline-delimited JSON) ready to POST to `/_bulk`.
|
|
16
16
|
* `.buildArray()` returns the raw operation objects if you need to inspect or transform them.
|
|
17
17
|
* @example
|
|
18
|
-
* const ndjson = bulk
|
|
18
|
+
* const ndjson = bulk(productMappings)
|
|
19
19
|
* .index({ id: '1', name: 'Product 1' }, { _index: 'products', _id: '1' })
|
|
20
20
|
* .create({ id: '2', name: 'Product 2' }, { _index: 'products', _id: '2' })
|
|
21
21
|
* .update({ _index: 'products', _id: '3', doc: { name: 'Updated' } })
|
|
@@ -24,7 +24,10 @@ export declare const createBulkBuilder: <T>(operations?: any[]) => BulkBuilder<T
|
|
|
24
24
|
*/
|
|
25
25
|
export declare const bulk: <M extends Record<string, FieldTypeString>>(_schema: MappingsSchema<M>) => BulkBuilder<{ [K in keyof M]: M[K] extends keyof {
|
|
26
26
|
text: string;
|
|
27
|
+
match_only_text: string;
|
|
27
28
|
keyword: string;
|
|
29
|
+
constant_keyword: string;
|
|
30
|
+
wildcard: string;
|
|
28
31
|
long: number;
|
|
29
32
|
integer: number;
|
|
30
33
|
short: number;
|
|
@@ -44,8 +47,10 @@ export declare const bulk: <M extends Record<string, FieldTypeString>>(_schema:
|
|
|
44
47
|
geo_shape: Record<string, unknown>;
|
|
45
48
|
dense_vector: number[];
|
|
46
49
|
completion: string;
|
|
50
|
+
search_as_you_type: string;
|
|
47
51
|
nested: unknown;
|
|
48
52
|
object: unknown;
|
|
53
|
+
flattened: Record<string, unknown>;
|
|
49
54
|
alias: unknown;
|
|
50
55
|
percolator: unknown;
|
|
51
56
|
integer_range: {
|
|
@@ -80,7 +85,10 @@ export declare const bulk: <M extends Record<string, FieldTypeString>>(_schema:
|
|
|
80
85
|
};
|
|
81
86
|
} ? {
|
|
82
87
|
text: string;
|
|
88
|
+
match_only_text: string;
|
|
83
89
|
keyword: string;
|
|
90
|
+
constant_keyword: string;
|
|
91
|
+
wildcard: string;
|
|
84
92
|
long: number;
|
|
85
93
|
integer: number;
|
|
86
94
|
short: number;
|
|
@@ -100,8 +108,10 @@ export declare const bulk: <M extends Record<string, FieldTypeString>>(_schema:
|
|
|
100
108
|
geo_shape: Record<string, unknown>;
|
|
101
109
|
dense_vector: number[];
|
|
102
110
|
completion: string;
|
|
111
|
+
search_as_you_type: string;
|
|
103
112
|
nested: unknown;
|
|
104
113
|
object: unknown;
|
|
114
|
+
flattened: Record<string, unknown>;
|
|
105
115
|
alias: unknown;
|
|
106
116
|
percolator: unknown;
|
|
107
117
|
integer_range: {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAiCd,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,SAAS,cAAc,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAE6F,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAAgC,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAA+B,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAAiC,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAA+B,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAA5U,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAAgC,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAA+B,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAAiC,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;;WAA+B,CAAC;WAAa,CAAC;UAAY,CAAC;UAAY,CAAC;;qBADpd,CAAC"}
|
package/dist/bulk.builder.js
CHANGED
|
@@ -18,23 +18,22 @@ operations = []) => ({
|
|
|
18
18
|
update: (meta) => {
|
|
19
19
|
const { doc, script, upsert, doc_as_upsert, ...header } = meta;
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
const updateDoc = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
updateDoc.upsert = upsert;
|
|
28
|
-
if (doc_as_upsert !== undefined)
|
|
29
|
-
updateDoc.doc_as_upsert = doc_as_upsert;
|
|
21
|
+
const updateDoc = {
|
|
22
|
+
...(doc && { doc }),
|
|
23
|
+
...(script && { script }),
|
|
24
|
+
...(upsert && { upsert }),
|
|
25
|
+
...(doc_as_upsert !== undefined && { doc_as_upsert })
|
|
26
|
+
};
|
|
30
27
|
return createBulkBuilder([...operations, { update: header }, updateDoc]);
|
|
31
28
|
},
|
|
32
29
|
delete: (meta) => {
|
|
33
30
|
return createBulkBuilder([...operations, { delete: meta }]);
|
|
34
31
|
},
|
|
32
|
+
// eslint-disable-next-line functional/functional-parameters
|
|
35
33
|
build: () => {
|
|
36
|
-
return operations.map((op) => JSON.stringify(op)).join('\n')
|
|
34
|
+
return `${operations.map((op) => JSON.stringify(op)).join('\n')}\n`;
|
|
37
35
|
},
|
|
36
|
+
// eslint-disable-next-line functional/functional-parameters
|
|
38
37
|
buildArray: () => operations
|
|
39
38
|
});
|
|
40
39
|
/**
|
|
@@ -42,7 +41,7 @@ operations = []) => ({
|
|
|
42
41
|
* `.build()` returns an NDJSON string (newline-delimited JSON) ready to POST to `/_bulk`.
|
|
43
42
|
* `.buildArray()` returns the raw operation objects if you need to inspect or transform them.
|
|
44
43
|
* @example
|
|
45
|
-
* const ndjson = bulk
|
|
44
|
+
* const ndjson = bulk(productMappings)
|
|
46
45
|
* .index({ id: '1', name: 'Product 1' }, { _index: 'products', _id: '1' })
|
|
47
46
|
* .create({ id: '2', name: 'Product 2' }, { _index: 'products', _id: '2' })
|
|
48
47
|
* .update({ _index: 'products', _id: '3', doc: { name: 'Updated' } })
|
package/dist/bulk.types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk.types.d.ts","sourceRoot":"","sources":["../src/bulk.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,mBAAmB,
|
|
1
|
+
{"version":3,"file":"bulk.types.d.ts","sourceRoot":"","sources":["../src/bulk.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,mBAAmB,GAAG,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,2CAA2C;IAC3C,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,aAAa,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IACxD,sDAAsD;IACtD,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IAC1D,kCAAkC;IAClC,MAAM,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IACpD,wBAAwB;IACxB,MAAM,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IACjD,sDAAsD;IACtD,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,gCAAgC;IAEhC,UAAU,EAAE,MAAM,GAAG,EAAE,CAAC;CACzB,CAAC"}
|
package/dist/field.helpers.d.ts
CHANGED
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
* embedding: denseVector({ dims: 384 }),
|
|
14
14
|
* });
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
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';
|
|
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';
|
|
18
17
|
export declare const text: (options?: TextFieldOptions) => TextFieldMapping;
|
|
19
18
|
export declare const keyword: (options?: KeywordFieldOptions) => KeywordFieldMapping;
|
|
20
19
|
export declare const long: (options?: NumericFieldOptions) => LongFieldMapping;
|
|
@@ -30,17 +29,73 @@ export declare const boolean: (options?: BooleanFieldOptions) => BooleanFieldMap
|
|
|
30
29
|
export declare const binary: () => BinaryFieldMapping;
|
|
31
30
|
export declare const ip: (options?: IpFieldOptions) => IpFieldMapping;
|
|
32
31
|
export declare const denseVector: (options?: DenseVectorFieldOptions) => DenseVectorFieldMapping;
|
|
32
|
+
/**
|
|
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;
|
|
33
64
|
export declare const geoPoint: (options?: GeoPointFieldOptions) => GeoPointFieldMapping;
|
|
34
65
|
export declare const geoShape: (options?: GeoShapeFieldOptions) => GeoShapeFieldMapping;
|
|
35
66
|
export declare const completion: (options?: CompletionFieldOptions) => CompletionFieldMapping;
|
|
36
67
|
export declare const nested: (fields?: NestedFields) => NestedFieldMapping;
|
|
37
68
|
export declare const object: (fields?: NestedFields, options?: ObjectFieldOptions) => ObjectFieldMapping;
|
|
38
|
-
export declare const alias: (options
|
|
69
|
+
export declare const alias: (options: AliasFieldOptions) => AliasFieldMapping;
|
|
39
70
|
export declare const percolator: () => PercolatorFieldMapping;
|
|
40
71
|
export declare const integerRange: (options?: RangeFieldOptions) => IntegerRangeFieldMapping;
|
|
41
72
|
export declare const floatRange: (options?: RangeFieldOptions) => FloatRangeFieldMapping;
|
|
42
73
|
export declare const longRange: (options?: RangeFieldOptions) => LongRangeFieldMapping;
|
|
43
74
|
export declare const doubleRange: (options?: RangeFieldOptions) => DoubleRangeFieldMapping;
|
|
44
75
|
export declare const dateRange: (options?: RangeFieldOptions) => DateRangeFieldMapping;
|
|
45
|
-
|
|
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.
|
|
99
|
+
*/
|
|
100
|
+
export declare const flattened: (options?: FlattenedFieldOptions) => FlattenedFieldMapping;
|
|
46
101
|
//# sourceMappingURL=field.helpers.d.ts.map
|