elasticlink 0.2.1-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 +30 -92
- 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
- package/dist/__tests__/aggregation-builder.test.d.ts +0 -2
- package/dist/__tests__/aggregation-builder.test.d.ts.map +0 -1
- package/dist/__tests__/aggregation-builder.test.js +0 -662
- package/dist/__tests__/bulk.test.d.ts +0 -2
- package/dist/__tests__/bulk.test.d.ts.map +0 -1
- package/dist/__tests__/bulk.test.js +0 -684
- package/dist/__tests__/examples.test.d.ts +0 -2
- package/dist/__tests__/examples.test.d.ts.map +0 -1
- package/dist/__tests__/examples.test.js +0 -2006
- package/dist/__tests__/fixtures/finance.d.ts +0 -26
- package/dist/__tests__/fixtures/finance.d.ts.map +0 -1
- package/dist/__tests__/fixtures/finance.js +0 -32
- package/dist/__tests__/fixtures/legal.d.ts +0 -8
- package/dist/__tests__/fixtures/legal.d.ts.map +0 -1
- package/dist/__tests__/fixtures/legal.js +0 -20
- package/dist/__tests__/fixtures/real-estate.d.ts +0 -19
- package/dist/__tests__/fixtures/real-estate.d.ts.map +0 -1
- package/dist/__tests__/fixtures/real-estate.js +0 -20
- package/dist/__tests__/index-management.test.d.ts +0 -2
- package/dist/__tests__/index-management.test.d.ts.map +0 -1
- package/dist/__tests__/index-management.test.js +0 -1148
- package/dist/__tests__/integration/aggregation.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/aggregation.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/aggregation.integration.test.js +0 -200
- package/dist/__tests__/integration/bulk.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/bulk.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/bulk.integration.test.js +0 -93
- package/dist/__tests__/integration/fixtures/finance.d.ts +0 -17
- package/dist/__tests__/integration/fixtures/finance.d.ts.map +0 -1
- package/dist/__tests__/integration/fixtures/finance.js +0 -42
- package/dist/__tests__/integration/fixtures/legal.d.ts +0 -21
- package/dist/__tests__/integration/fixtures/legal.d.ts.map +0 -1
- package/dist/__tests__/integration/fixtures/legal.js +0 -52
- package/dist/__tests__/integration/fixtures/real-estate.d.ts +0 -7
- package/dist/__tests__/integration/fixtures/real-estate.d.ts.map +0 -1
- package/dist/__tests__/integration/fixtures/real-estate.js +0 -22
- package/dist/__tests__/integration/helpers.d.ts +0 -15
- package/dist/__tests__/integration/helpers.d.ts.map +0 -1
- package/dist/__tests__/integration/helpers.js +0 -21
- package/dist/__tests__/integration/index-management.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/index-management.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/index-management.integration.test.js +0 -79
- package/dist/__tests__/integration/multi-search.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/multi-search.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/multi-search.integration.test.js +0 -55
- package/dist/__tests__/integration/query.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/query.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/query.integration.test.js +0 -118
- package/dist/__tests__/integration/suggester.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/suggester.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/suggester.integration.test.js +0 -48
- package/dist/__tests__/multi-search.test.d.ts +0 -2
- package/dist/__tests__/multi-search.test.d.ts.map +0 -1
- package/dist/__tests__/multi-search.test.js +0 -336
- package/dist/__tests__/query-builder.test.d.ts +0 -2
- package/dist/__tests__/query-builder.test.d.ts.map +0 -1
- package/dist/__tests__/query-builder.test.js +0 -5624
- package/dist/__tests__/suggester.test.d.ts +0 -2
- package/dist/__tests__/suggester.test.d.ts.map +0 -1
- package/dist/__tests__/suggester.test.js +0 -1001
|
@@ -1,684 +0,0 @@
|
|
|
1
|
-
import { bulk } from '..';
|
|
2
|
-
describe('Bulk API', () => {
|
|
3
|
-
describe('Builder behavior', () => {
|
|
4
|
-
it('should return trailing newline for empty build', () => {
|
|
5
|
-
const result = bulk().build();
|
|
6
|
-
expect(result).toBe('\n');
|
|
7
|
-
});
|
|
8
|
-
it('should return empty array for empty buildArray', () => {
|
|
9
|
-
const result = bulk().buildArray();
|
|
10
|
-
expect(result).toMatchInlineSnapshot(`[]`);
|
|
11
|
-
});
|
|
12
|
-
it('should chain multiple index operations', () => {
|
|
13
|
-
const result = bulk()
|
|
14
|
-
.index({
|
|
15
|
-
matter_id: 'M-1001',
|
|
16
|
-
title: 'Mergers & Acquisitions Advisory',
|
|
17
|
-
practice_area: 'corporate',
|
|
18
|
-
billing_rate: 850
|
|
19
|
-
}, { _index: 'matters', _id: '1' })
|
|
20
|
-
.index({
|
|
21
|
-
matter_id: 'M-1002',
|
|
22
|
-
title: 'SEC Compliance Review',
|
|
23
|
-
practice_area: 'securities',
|
|
24
|
-
billing_rate: 725
|
|
25
|
-
}, { _index: 'matters', _id: '2' })
|
|
26
|
-
.buildArray();
|
|
27
|
-
expect(result).toMatchInlineSnapshot(`
|
|
28
|
-
[
|
|
29
|
-
{
|
|
30
|
-
"index": {
|
|
31
|
-
"_id": "1",
|
|
32
|
-
"_index": "matters",
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"billing_rate": 850,
|
|
37
|
-
"matter_id": "M-1001",
|
|
38
|
-
"practice_area": "corporate",
|
|
39
|
-
"title": "Mergers & Acquisitions Advisory",
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"index": {
|
|
43
|
-
"_id": "2",
|
|
44
|
-
"_index": "matters",
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"billing_rate": 725,
|
|
49
|
-
"matter_id": "M-1002",
|
|
50
|
-
"practice_area": "securities",
|
|
51
|
-
"title": "SEC Compliance Review",
|
|
52
|
-
},
|
|
53
|
-
]
|
|
54
|
-
`);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe('Index operations', () => {
|
|
58
|
-
it('should build single index operation', () => {
|
|
59
|
-
const result = bulk()
|
|
60
|
-
.index({
|
|
61
|
-
matter_id: 'M-1001',
|
|
62
|
-
title: 'Acquisition Review',
|
|
63
|
-
practice_area: 'corporate',
|
|
64
|
-
billing_rate: 750
|
|
65
|
-
})
|
|
66
|
-
.build();
|
|
67
|
-
const lines = result.split('\n').filter((l) => l);
|
|
68
|
-
expect(lines).toHaveLength(2); // action + document
|
|
69
|
-
});
|
|
70
|
-
it('should index with metadata', () => {
|
|
71
|
-
const result = bulk()
|
|
72
|
-
.index({
|
|
73
|
-
matter_id: 'M-1001',
|
|
74
|
-
title: 'Acquisition Review',
|
|
75
|
-
practice_area: 'corporate',
|
|
76
|
-
billing_rate: 750
|
|
77
|
-
}, { _index: 'matters', _id: '1' })
|
|
78
|
-
.buildArray();
|
|
79
|
-
expect(result).toMatchInlineSnapshot(`
|
|
80
|
-
[
|
|
81
|
-
{
|
|
82
|
-
"index": {
|
|
83
|
-
"_id": "1",
|
|
84
|
-
"_index": "matters",
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"billing_rate": 750,
|
|
89
|
-
"matter_id": "M-1001",
|
|
90
|
-
"practice_area": "corporate",
|
|
91
|
-
"title": "Acquisition Review",
|
|
92
|
-
},
|
|
93
|
-
]
|
|
94
|
-
`);
|
|
95
|
-
});
|
|
96
|
-
it('should index with routing', () => {
|
|
97
|
-
const result = bulk()
|
|
98
|
-
.index({
|
|
99
|
-
matter_id: 'M-1001',
|
|
100
|
-
title: 'Acquisition Review',
|
|
101
|
-
practice_area: 'corporate',
|
|
102
|
-
billing_rate: 750
|
|
103
|
-
}, { routing: 'user-123' })
|
|
104
|
-
.buildArray();
|
|
105
|
-
expect(result).toMatchInlineSnapshot(`
|
|
106
|
-
[
|
|
107
|
-
{
|
|
108
|
-
"index": {
|
|
109
|
-
"routing": "user-123",
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"billing_rate": 750,
|
|
114
|
-
"matter_id": "M-1001",
|
|
115
|
-
"practice_area": "corporate",
|
|
116
|
-
"title": "Acquisition Review",
|
|
117
|
-
},
|
|
118
|
-
]
|
|
119
|
-
`);
|
|
120
|
-
});
|
|
121
|
-
it('should index with version', () => {
|
|
122
|
-
const result = bulk()
|
|
123
|
-
.index({
|
|
124
|
-
matter_id: 'M-1001',
|
|
125
|
-
title: 'Acquisition Review',
|
|
126
|
-
practice_area: 'corporate',
|
|
127
|
-
billing_rate: 750
|
|
128
|
-
}, { version: 5, version_type: 'external' })
|
|
129
|
-
.buildArray();
|
|
130
|
-
expect(result).toMatchInlineSnapshot(`
|
|
131
|
-
[
|
|
132
|
-
{
|
|
133
|
-
"index": {
|
|
134
|
-
"version": 5,
|
|
135
|
-
"version_type": "external",
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"billing_rate": 750,
|
|
140
|
-
"matter_id": "M-1001",
|
|
141
|
-
"practice_area": "corporate",
|
|
142
|
-
"title": "Acquisition Review",
|
|
143
|
-
},
|
|
144
|
-
]
|
|
145
|
-
`);
|
|
146
|
-
});
|
|
147
|
-
it('should index with pipeline', () => {
|
|
148
|
-
const result = bulk()
|
|
149
|
-
.index({
|
|
150
|
-
matter_id: 'M-1001',
|
|
151
|
-
title: 'Acquisition Review',
|
|
152
|
-
practice_area: 'corporate',
|
|
153
|
-
billing_rate: 750
|
|
154
|
-
}, { _index: 'matters', pipeline: 'enrichment-pipeline' })
|
|
155
|
-
.buildArray();
|
|
156
|
-
expect(result).toMatchInlineSnapshot(`
|
|
157
|
-
[
|
|
158
|
-
{
|
|
159
|
-
"index": {
|
|
160
|
-
"_index": "matters",
|
|
161
|
-
"pipeline": "enrichment-pipeline",
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
"billing_rate": 750,
|
|
166
|
-
"matter_id": "M-1001",
|
|
167
|
-
"practice_area": "corporate",
|
|
168
|
-
"title": "Acquisition Review",
|
|
169
|
-
},
|
|
170
|
-
]
|
|
171
|
-
`);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
describe('Create operations', () => {
|
|
175
|
-
it('should build create operation', () => {
|
|
176
|
-
const result = bulk()
|
|
177
|
-
.create({
|
|
178
|
-
matter_id: 'M-1002',
|
|
179
|
-
title: 'SEC Filing Review',
|
|
180
|
-
practice_area: 'securities',
|
|
181
|
-
billing_rate: 700
|
|
182
|
-
})
|
|
183
|
-
.build();
|
|
184
|
-
expect(result).toMatchInlineSnapshot(`
|
|
185
|
-
"{"create":{}}
|
|
186
|
-
{"matter_id":"M-1002","title":"SEC Filing Review","practice_area":"securities","billing_rate":700}
|
|
187
|
-
"
|
|
188
|
-
`);
|
|
189
|
-
});
|
|
190
|
-
it('should create with metadata', () => {
|
|
191
|
-
const result = bulk()
|
|
192
|
-
.create({
|
|
193
|
-
matter_id: 'M-1002',
|
|
194
|
-
title: 'SEC Filing Review',
|
|
195
|
-
practice_area: 'securities',
|
|
196
|
-
billing_rate: 700
|
|
197
|
-
}, { _index: 'matters', _id: '2' })
|
|
198
|
-
.buildArray();
|
|
199
|
-
expect(result).toMatchInlineSnapshot(`
|
|
200
|
-
[
|
|
201
|
-
{
|
|
202
|
-
"create": {
|
|
203
|
-
"_id": "2",
|
|
204
|
-
"_index": "matters",
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
"billing_rate": 700,
|
|
209
|
-
"matter_id": "M-1002",
|
|
210
|
-
"practice_area": "securities",
|
|
211
|
-
"title": "SEC Filing Review",
|
|
212
|
-
},
|
|
213
|
-
]
|
|
214
|
-
`);
|
|
215
|
-
});
|
|
216
|
-
it('should create with routing', () => {
|
|
217
|
-
const result = bulk()
|
|
218
|
-
.create({
|
|
219
|
-
matter_id: 'M-1003',
|
|
220
|
-
title: 'Patent Portfolio Review',
|
|
221
|
-
practice_area: 'intellectual-property',
|
|
222
|
-
billing_rate: 650
|
|
223
|
-
}, { _index: 'matters', _id: '3', routing: 'tenant-abc' })
|
|
224
|
-
.buildArray();
|
|
225
|
-
expect(result).toMatchInlineSnapshot(`
|
|
226
|
-
[
|
|
227
|
-
{
|
|
228
|
-
"create": {
|
|
229
|
-
"_id": "3",
|
|
230
|
-
"_index": "matters",
|
|
231
|
-
"routing": "tenant-abc",
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
"billing_rate": 650,
|
|
236
|
-
"matter_id": "M-1003",
|
|
237
|
-
"practice_area": "intellectual-property",
|
|
238
|
-
"title": "Patent Portfolio Review",
|
|
239
|
-
},
|
|
240
|
-
]
|
|
241
|
-
`);
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
describe('Update operations', () => {
|
|
245
|
-
it('should build update with doc', () => {
|
|
246
|
-
const result = bulk()
|
|
247
|
-
.update({
|
|
248
|
-
_index: 'matters',
|
|
249
|
-
_id: '3',
|
|
250
|
-
doc: { title: 'Updated Title', billing_rate: 150 }
|
|
251
|
-
})
|
|
252
|
-
.buildArray();
|
|
253
|
-
expect(result).toMatchInlineSnapshot(`
|
|
254
|
-
[
|
|
255
|
-
{
|
|
256
|
-
"update": {
|
|
257
|
-
"_id": "3",
|
|
258
|
-
"_index": "matters",
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
"doc": {
|
|
263
|
-
"billing_rate": 150,
|
|
264
|
-
"title": "Updated Title",
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
]
|
|
268
|
-
`);
|
|
269
|
-
});
|
|
270
|
-
it('should update with script', () => {
|
|
271
|
-
const result = bulk()
|
|
272
|
-
.update({
|
|
273
|
-
_index: 'matters',
|
|
274
|
-
_id: '4',
|
|
275
|
-
script: {
|
|
276
|
-
source: 'ctx._source.price += params.increment',
|
|
277
|
-
params: { increment: 10 }
|
|
278
|
-
}
|
|
279
|
-
})
|
|
280
|
-
.buildArray();
|
|
281
|
-
expect(result).toMatchInlineSnapshot(`
|
|
282
|
-
[
|
|
283
|
-
{
|
|
284
|
-
"update": {
|
|
285
|
-
"_id": "4",
|
|
286
|
-
"_index": "matters",
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
"script": {
|
|
291
|
-
"params": {
|
|
292
|
-
"increment": 10,
|
|
293
|
-
},
|
|
294
|
-
"source": "ctx._source.price += params.increment",
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
]
|
|
298
|
-
`);
|
|
299
|
-
});
|
|
300
|
-
it('should update with upsert', () => {
|
|
301
|
-
const result = bulk()
|
|
302
|
-
.update({
|
|
303
|
-
_index: 'matters',
|
|
304
|
-
_id: '5',
|
|
305
|
-
doc: {
|
|
306
|
-
title: 'Updated Matter',
|
|
307
|
-
billing_rate: 900,
|
|
308
|
-
practice_area: 'corporate',
|
|
309
|
-
matter_id: 'M-5'
|
|
310
|
-
},
|
|
311
|
-
upsert: {
|
|
312
|
-
matter_id: 'M-5',
|
|
313
|
-
title: 'New Matter',
|
|
314
|
-
billing_rate: 900,
|
|
315
|
-
practice_area: 'corporate'
|
|
316
|
-
}
|
|
317
|
-
})
|
|
318
|
-
.buildArray();
|
|
319
|
-
expect(result).toMatchInlineSnapshot(`
|
|
320
|
-
[
|
|
321
|
-
{
|
|
322
|
-
"update": {
|
|
323
|
-
"_id": "5",
|
|
324
|
-
"_index": "matters",
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
"doc": {
|
|
329
|
-
"billing_rate": 900,
|
|
330
|
-
"matter_id": "M-5",
|
|
331
|
-
"practice_area": "corporate",
|
|
332
|
-
"title": "Updated Matter",
|
|
333
|
-
},
|
|
334
|
-
"upsert": {
|
|
335
|
-
"billing_rate": 900,
|
|
336
|
-
"matter_id": "M-5",
|
|
337
|
-
"practice_area": "corporate",
|
|
338
|
-
"title": "New Matter",
|
|
339
|
-
},
|
|
340
|
-
},
|
|
341
|
-
]
|
|
342
|
-
`);
|
|
343
|
-
});
|
|
344
|
-
it('should update with doc_as_upsert', () => {
|
|
345
|
-
const result = bulk()
|
|
346
|
-
.update({
|
|
347
|
-
_index: 'matters',
|
|
348
|
-
_id: '6',
|
|
349
|
-
doc: {
|
|
350
|
-
matter_id: 'M-6',
|
|
351
|
-
title: 'IP Dispute',
|
|
352
|
-
billing_rate: 800,
|
|
353
|
-
practice_area: 'intellectual-property'
|
|
354
|
-
},
|
|
355
|
-
doc_as_upsert: true
|
|
356
|
-
})
|
|
357
|
-
.buildArray();
|
|
358
|
-
expect(result).toMatchInlineSnapshot(`
|
|
359
|
-
[
|
|
360
|
-
{
|
|
361
|
-
"update": {
|
|
362
|
-
"_id": "6",
|
|
363
|
-
"_index": "matters",
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
"doc": {
|
|
368
|
-
"billing_rate": 800,
|
|
369
|
-
"matter_id": "M-6",
|
|
370
|
-
"practice_area": "intellectual-property",
|
|
371
|
-
"title": "IP Dispute",
|
|
372
|
-
},
|
|
373
|
-
"doc_as_upsert": true,
|
|
374
|
-
},
|
|
375
|
-
]
|
|
376
|
-
`);
|
|
377
|
-
});
|
|
378
|
-
it('should update with retry_on_conflict', () => {
|
|
379
|
-
const result = bulk()
|
|
380
|
-
.update({
|
|
381
|
-
_index: 'matters',
|
|
382
|
-
_id: '7',
|
|
383
|
-
doc: { billing_rate: 200 },
|
|
384
|
-
retry_on_conflict: 3
|
|
385
|
-
})
|
|
386
|
-
.buildArray();
|
|
387
|
-
expect(result).toMatchInlineSnapshot(`
|
|
388
|
-
[
|
|
389
|
-
{
|
|
390
|
-
"update": {
|
|
391
|
-
"_id": "7",
|
|
392
|
-
"_index": "matters",
|
|
393
|
-
"retry_on_conflict": 3,
|
|
394
|
-
},
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
"doc": {
|
|
398
|
-
"billing_rate": 200,
|
|
399
|
-
},
|
|
400
|
-
},
|
|
401
|
-
]
|
|
402
|
-
`);
|
|
403
|
-
});
|
|
404
|
-
});
|
|
405
|
-
describe('Delete operations', () => {
|
|
406
|
-
it('should build delete operation', () => {
|
|
407
|
-
const result = bulk()
|
|
408
|
-
.delete({ _index: 'matters', _id: '8' })
|
|
409
|
-
.buildArray();
|
|
410
|
-
expect(result).toMatchInlineSnapshot(`
|
|
411
|
-
[
|
|
412
|
-
{
|
|
413
|
-
"delete": {
|
|
414
|
-
"_id": "8",
|
|
415
|
-
"_index": "matters",
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
]
|
|
419
|
-
`);
|
|
420
|
-
});
|
|
421
|
-
it('should delete with routing', () => {
|
|
422
|
-
const result = bulk()
|
|
423
|
-
.delete({ _index: 'matters', _id: '9', routing: 'user-456' })
|
|
424
|
-
.buildArray();
|
|
425
|
-
expect(result).toMatchInlineSnapshot(`
|
|
426
|
-
[
|
|
427
|
-
{
|
|
428
|
-
"delete": {
|
|
429
|
-
"_id": "9",
|
|
430
|
-
"_index": "matters",
|
|
431
|
-
"routing": "user-456",
|
|
432
|
-
},
|
|
433
|
-
},
|
|
434
|
-
]
|
|
435
|
-
`);
|
|
436
|
-
});
|
|
437
|
-
it('should delete with version', () => {
|
|
438
|
-
const result = bulk()
|
|
439
|
-
.delete({ _index: 'matters', _id: '10', version: 3 })
|
|
440
|
-
.buildArray();
|
|
441
|
-
expect(result).toMatchInlineSnapshot(`
|
|
442
|
-
[
|
|
443
|
-
{
|
|
444
|
-
"delete": {
|
|
445
|
-
"_id": "10",
|
|
446
|
-
"_index": "matters",
|
|
447
|
-
"version": 3,
|
|
448
|
-
},
|
|
449
|
-
},
|
|
450
|
-
]
|
|
451
|
-
`);
|
|
452
|
-
});
|
|
453
|
-
it('should delete with version and version_type', () => {
|
|
454
|
-
const result = bulk()
|
|
455
|
-
.delete({
|
|
456
|
-
_index: 'matters',
|
|
457
|
-
_id: '11',
|
|
458
|
-
version: 7,
|
|
459
|
-
version_type: 'external'
|
|
460
|
-
})
|
|
461
|
-
.buildArray();
|
|
462
|
-
expect(result).toMatchInlineSnapshot(`
|
|
463
|
-
[
|
|
464
|
-
{
|
|
465
|
-
"delete": {
|
|
466
|
-
"_id": "11",
|
|
467
|
-
"_index": "matters",
|
|
468
|
-
"version": 7,
|
|
469
|
-
"version_type": "external",
|
|
470
|
-
},
|
|
471
|
-
},
|
|
472
|
-
]
|
|
473
|
-
`);
|
|
474
|
-
});
|
|
475
|
-
});
|
|
476
|
-
describe('Mixed operations', () => {
|
|
477
|
-
it('should combine multiple operation types', () => {
|
|
478
|
-
const result = bulk()
|
|
479
|
-
.index({
|
|
480
|
-
matter_id: 'M-2001',
|
|
481
|
-
title: 'Contract Negotiation',
|
|
482
|
-
practice_area: 'corporate',
|
|
483
|
-
billing_rate: 800
|
|
484
|
-
}, { _index: 'matters', _id: '1' })
|
|
485
|
-
.create({
|
|
486
|
-
matter_id: 'M-2002',
|
|
487
|
-
title: 'Regulatory Compliance',
|
|
488
|
-
practice_area: 'securities',
|
|
489
|
-
billing_rate: 750
|
|
490
|
-
}, { _index: 'matters', _id: '2' })
|
|
491
|
-
.update({
|
|
492
|
-
_index: 'matters',
|
|
493
|
-
_id: '3',
|
|
494
|
-
doc: { title: 'Updated Matter 3' }
|
|
495
|
-
})
|
|
496
|
-
.delete({ _index: 'matters', _id: '4' })
|
|
497
|
-
.buildArray();
|
|
498
|
-
expect(result).toMatchInlineSnapshot(`
|
|
499
|
-
[
|
|
500
|
-
{
|
|
501
|
-
"index": {
|
|
502
|
-
"_id": "1",
|
|
503
|
-
"_index": "matters",
|
|
504
|
-
},
|
|
505
|
-
},
|
|
506
|
-
{
|
|
507
|
-
"billing_rate": 800,
|
|
508
|
-
"matter_id": "M-2001",
|
|
509
|
-
"practice_area": "corporate",
|
|
510
|
-
"title": "Contract Negotiation",
|
|
511
|
-
},
|
|
512
|
-
{
|
|
513
|
-
"create": {
|
|
514
|
-
"_id": "2",
|
|
515
|
-
"_index": "matters",
|
|
516
|
-
},
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
"billing_rate": 750,
|
|
520
|
-
"matter_id": "M-2002",
|
|
521
|
-
"practice_area": "securities",
|
|
522
|
-
"title": "Regulatory Compliance",
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
"update": {
|
|
526
|
-
"_id": "3",
|
|
527
|
-
"_index": "matters",
|
|
528
|
-
},
|
|
529
|
-
},
|
|
530
|
-
{
|
|
531
|
-
"doc": {
|
|
532
|
-
"title": "Updated Matter 3",
|
|
533
|
-
},
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
"delete": {
|
|
537
|
-
"_id": "4",
|
|
538
|
-
"_index": "matters",
|
|
539
|
-
},
|
|
540
|
-
},
|
|
541
|
-
]
|
|
542
|
-
`);
|
|
543
|
-
});
|
|
544
|
-
});
|
|
545
|
-
describe('Bulk output formats', () => {
|
|
546
|
-
it('should build as NDJSON string', () => {
|
|
547
|
-
const result = bulk()
|
|
548
|
-
.index({
|
|
549
|
-
matter_id: 'M-1001',
|
|
550
|
-
title: 'Acquisition Review',
|
|
551
|
-
practice_area: 'corporate',
|
|
552
|
-
billing_rate: 750
|
|
553
|
-
})
|
|
554
|
-
.build();
|
|
555
|
-
expect(result).toMatchInlineSnapshot(`
|
|
556
|
-
"{"index":{}}
|
|
557
|
-
{"matter_id":"M-1001","title":"Acquisition Review","practice_area":"corporate","billing_rate":750}
|
|
558
|
-
"
|
|
559
|
-
`);
|
|
560
|
-
});
|
|
561
|
-
it('should build as array', () => {
|
|
562
|
-
const result = bulk()
|
|
563
|
-
.index({
|
|
564
|
-
matter_id: 'M-1001',
|
|
565
|
-
title: 'Acquisition Review',
|
|
566
|
-
practice_area: 'corporate',
|
|
567
|
-
billing_rate: 750
|
|
568
|
-
})
|
|
569
|
-
.buildArray();
|
|
570
|
-
expect(result).toMatchInlineSnapshot(`
|
|
571
|
-
[
|
|
572
|
-
{
|
|
573
|
-
"index": {},
|
|
574
|
-
},
|
|
575
|
-
{
|
|
576
|
-
"billing_rate": 750,
|
|
577
|
-
"matter_id": "M-1001",
|
|
578
|
-
"practice_area": "corporate",
|
|
579
|
-
"title": "Acquisition Review",
|
|
580
|
-
},
|
|
581
|
-
]
|
|
582
|
-
`);
|
|
583
|
-
});
|
|
584
|
-
});
|
|
585
|
-
describe('Real-world bulk scenarios', () => {
|
|
586
|
-
it('should batch matter index operations', () => {
|
|
587
|
-
const matters = [
|
|
588
|
-
{
|
|
589
|
-
matter_id: 'M-1001',
|
|
590
|
-
title: 'Mergers & Acquisitions Advisory',
|
|
591
|
-
practice_area: 'corporate',
|
|
592
|
-
billing_rate: 850
|
|
593
|
-
},
|
|
594
|
-
{
|
|
595
|
-
matter_id: 'M-1002',
|
|
596
|
-
title: 'SEC Compliance Review',
|
|
597
|
-
practice_area: 'securities',
|
|
598
|
-
billing_rate: 725
|
|
599
|
-
},
|
|
600
|
-
{
|
|
601
|
-
matter_id: 'M-1003',
|
|
602
|
-
title: 'IP Portfolio Audit',
|
|
603
|
-
practice_area: 'intellectual-property',
|
|
604
|
-
billing_rate: 650
|
|
605
|
-
}
|
|
606
|
-
];
|
|
607
|
-
let bulkOp = bulk();
|
|
608
|
-
for (const matter of matters) {
|
|
609
|
-
bulkOp = bulkOp.index(matter, {
|
|
610
|
-
_index: 'matters',
|
|
611
|
-
_id: matter.matter_id
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
const result = bulkOp.buildArray();
|
|
615
|
-
expect(result).toMatchInlineSnapshot(`
|
|
616
|
-
[
|
|
617
|
-
{
|
|
618
|
-
"index": {
|
|
619
|
-
"_id": "M-1001",
|
|
620
|
-
"_index": "matters",
|
|
621
|
-
},
|
|
622
|
-
},
|
|
623
|
-
{
|
|
624
|
-
"billing_rate": 850,
|
|
625
|
-
"matter_id": "M-1001",
|
|
626
|
-
"practice_area": "corporate",
|
|
627
|
-
"title": "Mergers & Acquisitions Advisory",
|
|
628
|
-
},
|
|
629
|
-
{
|
|
630
|
-
"index": {
|
|
631
|
-
"_id": "M-1002",
|
|
632
|
-
"_index": "matters",
|
|
633
|
-
},
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
"billing_rate": 725,
|
|
637
|
-
"matter_id": "M-1002",
|
|
638
|
-
"practice_area": "securities",
|
|
639
|
-
"title": "SEC Compliance Review",
|
|
640
|
-
},
|
|
641
|
-
{
|
|
642
|
-
"index": {
|
|
643
|
-
"_id": "M-1003",
|
|
644
|
-
"_index": "matters",
|
|
645
|
-
},
|
|
646
|
-
},
|
|
647
|
-
{
|
|
648
|
-
"billing_rate": 650,
|
|
649
|
-
"matter_id": "M-1003",
|
|
650
|
-
"practice_area": "intellectual-property",
|
|
651
|
-
"title": "IP Portfolio Audit",
|
|
652
|
-
},
|
|
653
|
-
]
|
|
654
|
-
`);
|
|
655
|
-
});
|
|
656
|
-
it('should handle mixed CRUD operations', () => {
|
|
657
|
-
const result = bulk()
|
|
658
|
-
// Create new products
|
|
659
|
-
.create({
|
|
660
|
-
matter_id: 'M-5000',
|
|
661
|
-
title: 'Cross-Border M&A',
|
|
662
|
-
practice_area: 'corporate',
|
|
663
|
-
billing_rate: 950
|
|
664
|
-
}, { _index: 'matters', _id: '100' })
|
|
665
|
-
// Update existing
|
|
666
|
-
.update({
|
|
667
|
-
_index: 'matters',
|
|
668
|
-
_id: '50',
|
|
669
|
-
doc: { billing_rate: 450 }
|
|
670
|
-
})
|
|
671
|
-
// Delete old
|
|
672
|
-
.delete({ _index: 'matters', _id: '25' })
|
|
673
|
-
.build();
|
|
674
|
-
expect(result).toMatchInlineSnapshot(`
|
|
675
|
-
"{"create":{"_index":"matters","_id":"100"}}
|
|
676
|
-
{"matter_id":"M-5000","title":"Cross-Border M&A","practice_area":"corporate","billing_rate":950}
|
|
677
|
-
{"update":{"_index":"matters","_id":"50"}}
|
|
678
|
-
{"doc":{"billing_rate":450}}
|
|
679
|
-
{"delete":{"_index":"matters","_id":"25"}}
|
|
680
|
-
"
|
|
681
|
-
`);
|
|
682
|
-
});
|
|
683
|
-
});
|
|
684
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"examples.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/examples.test.ts"],"names":[],"mappings":""}
|