elasticlink 0.3.0-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 +61 -14
- 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.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 +6 -3
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).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregation-builder.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/aggregation-builder.test.ts"],"names":[],"mappings":""}
|