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