elasticlink 0.4.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.
Files changed (67) hide show
  1. package/package.json +2 -2
  2. package/dist/__tests__/aggregation-builder.test.d.ts +0 -2
  3. package/dist/__tests__/aggregation-builder.test.d.ts.map +0 -1
  4. package/dist/__tests__/aggregation-builder.test.js +0 -622
  5. package/dist/__tests__/bulk.test.d.ts +0 -2
  6. package/dist/__tests__/bulk.test.d.ts.map +0 -1
  7. package/dist/__tests__/bulk.test.js +0 -679
  8. package/dist/__tests__/examples.test.d.ts +0 -2
  9. package/dist/__tests__/examples.test.d.ts.map +0 -1
  10. package/dist/__tests__/examples.test.js +0 -2123
  11. package/dist/__tests__/fixtures/finance.d.ts +0 -58
  12. package/dist/__tests__/fixtures/finance.d.ts.map +0 -1
  13. package/dist/__tests__/fixtures/finance.js +0 -73
  14. package/dist/__tests__/fixtures/legal.d.ts +0 -14
  15. package/dist/__tests__/fixtures/legal.d.ts.map +0 -1
  16. package/dist/__tests__/fixtures/legal.js +0 -27
  17. package/dist/__tests__/fixtures/real-estate.d.ts +0 -31
  18. package/dist/__tests__/fixtures/real-estate.d.ts.map +0 -1
  19. package/dist/__tests__/fixtures/real-estate.js +0 -39
  20. package/dist/__tests__/index-management.test.d.ts +0 -2
  21. package/dist/__tests__/index-management.test.d.ts.map +0 -1
  22. package/dist/__tests__/index-management.test.js +0 -1699
  23. package/dist/__tests__/integration/aggregation.integration.test.d.ts +0 -2
  24. package/dist/__tests__/integration/aggregation.integration.test.d.ts.map +0 -1
  25. package/dist/__tests__/integration/aggregation.integration.test.js +0 -188
  26. package/dist/__tests__/integration/bulk.integration.test.d.ts +0 -2
  27. package/dist/__tests__/integration/bulk.integration.test.d.ts.map +0 -1
  28. package/dist/__tests__/integration/bulk.integration.test.js +0 -90
  29. package/dist/__tests__/integration/fixtures/finance.d.ts +0 -37
  30. package/dist/__tests__/integration/fixtures/finance.d.ts.map +0 -1
  31. package/dist/__tests__/integration/fixtures/finance.js +0 -58
  32. package/dist/__tests__/integration/fixtures/legal.d.ts +0 -38
  33. package/dist/__tests__/integration/fixtures/legal.d.ts.map +0 -1
  34. package/dist/__tests__/integration/fixtures/legal.js +0 -65
  35. package/dist/__tests__/integration/fixtures/real-estate.d.ts +0 -17
  36. package/dist/__tests__/integration/fixtures/real-estate.d.ts.map +0 -1
  37. package/dist/__tests__/integration/fixtures/real-estate.js +0 -28
  38. package/dist/__tests__/integration/helpers.d.ts +0 -15
  39. package/dist/__tests__/integration/helpers.d.ts.map +0 -1
  40. package/dist/__tests__/integration/helpers.js +0 -21
  41. package/dist/__tests__/integration/index-management.integration.test.d.ts +0 -2
  42. package/dist/__tests__/integration/index-management.integration.test.d.ts.map +0 -1
  43. package/dist/__tests__/integration/index-management.integration.test.js +0 -67
  44. package/dist/__tests__/integration/multi-search.integration.test.d.ts +0 -2
  45. package/dist/__tests__/integration/multi-search.integration.test.d.ts.map +0 -1
  46. package/dist/__tests__/integration/multi-search.integration.test.js +0 -49
  47. package/dist/__tests__/integration/query.integration.test.d.ts +0 -2
  48. package/dist/__tests__/integration/query.integration.test.d.ts.map +0 -1
  49. package/dist/__tests__/integration/query.integration.test.js +0 -101
  50. package/dist/__tests__/integration/suggester.integration.test.d.ts +0 -2
  51. package/dist/__tests__/integration/suggester.integration.test.d.ts.map +0 -1
  52. package/dist/__tests__/integration/suggester.integration.test.js +0 -42
  53. package/dist/__tests__/multi-search.test.d.ts +0 -2
  54. package/dist/__tests__/multi-search.test.d.ts.map +0 -1
  55. package/dist/__tests__/multi-search.test.js +0 -325
  56. package/dist/__tests__/query-builder-extensions.test.d.ts +0 -2
  57. package/dist/__tests__/query-builder-extensions.test.d.ts.map +0 -1
  58. package/dist/__tests__/query-builder-extensions.test.js +0 -436
  59. package/dist/__tests__/query-builder.test.d.ts +0 -2
  60. package/dist/__tests__/query-builder.test.d.ts.map +0 -1
  61. package/dist/__tests__/query-builder.test.js +0 -5482
  62. package/dist/__tests__/settings-presets.test.d.ts +0 -2
  63. package/dist/__tests__/settings-presets.test.d.ts.map +0 -1
  64. package/dist/__tests__/settings-presets.test.js +0 -183
  65. package/dist/__tests__/suggester.test.d.ts +0 -2
  66. package/dist/__tests__/suggester.test.d.ts.map +0 -1
  67. package/dist/__tests__/suggester.test.js +0 -1006
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elasticlink",
3
- "version": "0.4.0-beta",
3
+ "version": "0.4.1-beta",
4
4
  "description": "Type-safe, lightweight Elasticsearch query builder with fluent API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "dist"
18
18
  ],
19
19
  "scripts": {
20
- "build": "tsc",
20
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
21
21
  "test": "vitest run",
22
22
  "test:integration": "vitest run --config vitest.integration.config.ts",
23
23
  "test:watch": "vitest",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=aggregation-builder.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aggregation-builder.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/aggregation-builder.test.ts"],"names":[],"mappings":""}
@@ -1,622 +0,0 @@
1
- import { aggregations } from '..';
2
- import { listingDetailMappings } from './fixtures/real-estate.js';
3
- describe('AggregationBuilder', () => {
4
- describe('Builder behavior', () => {
5
- it('should return empty object for empty builder', () => {
6
- const result = aggregations(listingDetailMappings).build();
7
- expect(result).toMatchInlineSnapshot(`{}`);
8
- });
9
- it('should support multiple top-level aggregations at same level', () => {
10
- const result = aggregations(listingDetailMappings)
11
- .terms('by_property_class', 'property_class')
12
- .avg('avg_price', 'list_price')
13
- .dateHistogram('over_time', 'listed_date', { interval: 'month' })
14
- .build();
15
- expect(result).toMatchInlineSnapshot(`
16
- {
17
- "avg_price": {
18
- "avg": {
19
- "field": "list_price",
20
- },
21
- },
22
- "by_property_class": {
23
- "terms": {
24
- "field": "property_class",
25
- },
26
- },
27
- "over_time": {
28
- "date_histogram": {
29
- "field": "listed_date",
30
- "interval": "month",
31
- },
32
- },
33
- }
34
- `);
35
- });
36
- });
37
- describe('Bucket aggregations', () => {
38
- it('should create a terms aggregation', () => {
39
- const result = aggregations(listingDetailMappings).terms('category_agg', 'property_class', { size: 10 }).build();
40
- expect(result).toMatchInlineSnapshot(`
41
- {
42
- "category_agg": {
43
- "terms": {
44
- "field": "property_class",
45
- "size": 10,
46
- },
47
- },
48
- }
49
- `);
50
- });
51
- it('should create a terms aggregation without options', () => {
52
- const result = aggregations(listingDetailMappings).terms('category_agg', 'property_class').build();
53
- expect(result).toMatchInlineSnapshot(`
54
- {
55
- "category_agg": {
56
- "terms": {
57
- "field": "property_class",
58
- },
59
- },
60
- }
61
- `);
62
- });
63
- it('should create a date histogram aggregation', () => {
64
- const result = aggregations(listingDetailMappings)
65
- .dateHistogram('listings_by_date', 'listed_date', {
66
- interval: 'day',
67
- min_doc_count: 1
68
- })
69
- .build();
70
- expect(result).toMatchInlineSnapshot(`
71
- {
72
- "listings_by_date": {
73
- "date_histogram": {
74
- "field": "listed_date",
75
- "interval": "day",
76
- "min_doc_count": 1,
77
- },
78
- },
79
- }
80
- `);
81
- });
82
- it('should create a range aggregation', () => {
83
- const result = aggregations(listingDetailMappings)
84
- .range('price_ranges', 'list_price', {
85
- ranges: [{ to: 100 }, { from: 100, to: 500 }, { from: 500 }]
86
- })
87
- .build();
88
- expect(result).toMatchInlineSnapshot(`
89
- {
90
- "price_ranges": {
91
- "range": {
92
- "field": "list_price",
93
- "ranges": [
94
- {
95
- "to": 100,
96
- },
97
- {
98
- "from": 100,
99
- "to": 500,
100
- },
101
- {
102
- "from": 500,
103
- },
104
- ],
105
- },
106
- },
107
- }
108
- `);
109
- });
110
- it('should create a histogram aggregation', () => {
111
- const result = aggregations(listingDetailMappings)
112
- .histogram('price_histogram', 'list_price', { interval: 50 })
113
- .build();
114
- expect(result).toMatchInlineSnapshot(`
115
- {
116
- "price_histogram": {
117
- "histogram": {
118
- "field": "list_price",
119
- "interval": 50,
120
- },
121
- },
122
- }
123
- `);
124
- });
125
- });
126
- describe('Metric aggregations', () => {
127
- it('should create an avg aggregation', () => {
128
- const result = aggregations(listingDetailMappings).avg('avg_price', 'list_price').build();
129
- expect(result).toMatchInlineSnapshot(`
130
- {
131
- "avg_price": {
132
- "avg": {
133
- "field": "list_price",
134
- },
135
- },
136
- }
137
- `);
138
- });
139
- it('should create a sum aggregation', () => {
140
- const result = aggregations(listingDetailMappings).sum('total_price', 'list_price').build();
141
- expect(result).toMatchInlineSnapshot(`
142
- {
143
- "total_price": {
144
- "sum": {
145
- "field": "list_price",
146
- },
147
- },
148
- }
149
- `);
150
- });
151
- it('should create a min aggregation', () => {
152
- const result = aggregations(listingDetailMappings).min('min_price', 'list_price').build();
153
- expect(result).toMatchInlineSnapshot(`
154
- {
155
- "min_price": {
156
- "min": {
157
- "field": "list_price",
158
- },
159
- },
160
- }
161
- `);
162
- });
163
- it('should create a max aggregation', () => {
164
- const result = aggregations(listingDetailMappings).max('max_price', 'list_price').build();
165
- expect(result).toMatchInlineSnapshot(`
166
- {
167
- "max_price": {
168
- "max": {
169
- "field": "list_price",
170
- },
171
- },
172
- }
173
- `);
174
- });
175
- it('should create a cardinality aggregation', () => {
176
- const result = aggregations(listingDetailMappings)
177
- .cardinality('unique_categories', 'property_class', {
178
- precision_threshold: 100
179
- })
180
- .build();
181
- expect(result).toMatchInlineSnapshot(`
182
- {
183
- "unique_categories": {
184
- "cardinality": {
185
- "field": "property_class",
186
- "precision_threshold": 100,
187
- },
188
- },
189
- }
190
- `);
191
- });
192
- it('should create a percentiles aggregation', () => {
193
- const result = aggregations(listingDetailMappings)
194
- .percentiles('price_percentiles', 'list_price', {
195
- percents: [25, 50, 75, 95]
196
- })
197
- .build();
198
- expect(result).toMatchInlineSnapshot(`
199
- {
200
- "price_percentiles": {
201
- "percentiles": {
202
- "field": "list_price",
203
- "percents": [
204
- 25,
205
- 50,
206
- 75,
207
- 95,
208
- ],
209
- },
210
- },
211
- }
212
- `);
213
- });
214
- it('should create a percentiles aggregation with no options', () => {
215
- const result = aggregations(listingDetailMappings).percentiles('price_percentiles', 'list_price').build();
216
- expect(result).toMatchInlineSnapshot(`
217
- {
218
- "price_percentiles": {
219
- "percentiles": {
220
- "field": "list_price",
221
- },
222
- },
223
- }
224
- `);
225
- });
226
- it('should create a stats aggregation', () => {
227
- const result = aggregations(listingDetailMappings).stats('price_stats', 'list_price').build();
228
- expect(result).toMatchInlineSnapshot(`
229
- {
230
- "price_stats": {
231
- "stats": {
232
- "field": "list_price",
233
- },
234
- },
235
- }
236
- `);
237
- });
238
- it('should create a value_count aggregation', () => {
239
- const result = aggregations(listingDetailMappings).valueCount('rating_count', 'cap_rate').build();
240
- expect(result).toMatchInlineSnapshot(`
241
- {
242
- "rating_count": {
243
- "value_count": {
244
- "field": "cap_rate",
245
- },
246
- },
247
- }
248
- `);
249
- });
250
- });
251
- describe('Sub-aggregations', () => {
252
- it('should add sub-aggregations to a bucket aggregation', () => {
253
- const result = aggregations(listingDetailMappings)
254
- .terms('categories', 'property_class', { size: 10 })
255
- .subAgg((agg) => agg.avg('avg_price', 'list_price'))
256
- .build();
257
- expect(result).toMatchInlineSnapshot(`
258
- {
259
- "categories": {
260
- "aggs": {
261
- "avg_price": {
262
- "avg": {
263
- "field": "list_price",
264
- },
265
- },
266
- },
267
- "terms": {
268
- "field": "property_class",
269
- "size": 10,
270
- },
271
- },
272
- }
273
- `);
274
- });
275
- it('should add multiple sub-aggregations', () => {
276
- const result = aggregations(listingDetailMappings)
277
- .terms('categories', 'property_class')
278
- .subAgg((agg) => agg.avg('avg_price', 'list_price').max('max_rating', 'cap_rate'))
279
- .build();
280
- expect(result).toMatchInlineSnapshot(`
281
- {
282
- "categories": {
283
- "aggs": {
284
- "avg_price": {
285
- "avg": {
286
- "field": "list_price",
287
- },
288
- },
289
- "max_rating": {
290
- "max": {
291
- "field": "cap_rate",
292
- },
293
- },
294
- },
295
- "terms": {
296
- "field": "property_class",
297
- },
298
- },
299
- }
300
- `);
301
- });
302
- });
303
- describe('Aggregation options', () => {
304
- describe('Terms aggregation options', () => {
305
- it('should create terms with min_doc_count', () => {
306
- const result = aggregations(listingDetailMappings)
307
- .terms('categories', 'property_class', { min_doc_count: 5 })
308
- .build();
309
- expect(result).toMatchInlineSnapshot(`
310
- {
311
- "categories": {
312
- "terms": {
313
- "field": "property_class",
314
- "min_doc_count": 5,
315
- },
316
- },
317
- }
318
- `);
319
- });
320
- it('should create terms with order', () => {
321
- const result = aggregations(listingDetailMappings)
322
- .terms('categories', 'property_class', { order: { _count: 'asc' } })
323
- .build();
324
- expect(result).toMatchInlineSnapshot(`
325
- {
326
- "categories": {
327
- "terms": {
328
- "field": "property_class",
329
- "order": {
330
- "_count": "asc",
331
- },
332
- },
333
- },
334
- }
335
- `);
336
- });
337
- it('should create terms with missing value', () => {
338
- const result = aggregations(listingDetailMappings)
339
- .terms('categories', 'property_class', { missing: 'N/A' })
340
- .build();
341
- expect(result).toMatchInlineSnapshot(`
342
- {
343
- "categories": {
344
- "terms": {
345
- "field": "property_class",
346
- "missing": "N/A",
347
- },
348
- },
349
- }
350
- `);
351
- });
352
- it('should create terms with all options', () => {
353
- const result = aggregations(listingDetailMappings)
354
- .terms('categories', 'property_class', {
355
- size: 20,
356
- min_doc_count: 2,
357
- order: { _key: 'desc' },
358
- missing: 'Unknown'
359
- })
360
- .build();
361
- expect(result.categories.terms).toStrictEqual({
362
- field: 'property_class',
363
- size: 20,
364
- min_doc_count: 2,
365
- order: { _key: 'desc' },
366
- missing: 'Unknown'
367
- });
368
- });
369
- });
370
- describe('Range aggregation options', () => {
371
- it('should create range with keyed ranges', () => {
372
- const result = aggregations(listingDetailMappings)
373
- .range('price_ranges', 'list_price', {
374
- ranges: [
375
- { key: 'cheap', to: 100 },
376
- { key: 'moderate', from: 100, to: 500 },
377
- { key: 'expensive', from: 500 }
378
- ]
379
- })
380
- .build();
381
- expect(result.price_ranges.range.ranges).toMatchInlineSnapshot(`
382
- [
383
- {
384
- "key": "cheap",
385
- "to": 100,
386
- },
387
- {
388
- "from": 100,
389
- "key": "moderate",
390
- "to": 500,
391
- },
392
- {
393
- "from": 500,
394
- "key": "expensive",
395
- },
396
- ]
397
- `);
398
- });
399
- });
400
- describe('DateHistogram aggregation options', () => {
401
- it('should create dateHistogram with minimal options', () => {
402
- const result = aggregations(listingDetailMappings)
403
- .dateHistogram('by_day', 'listed_date', { interval: 'day' })
404
- .build();
405
- expect(result).toMatchInlineSnapshot(`
406
- {
407
- "by_day": {
408
- "date_histogram": {
409
- "field": "listed_date",
410
- "interval": "day",
411
- },
412
- },
413
- }
414
- `);
415
- });
416
- it('should create dateHistogram with extended_bounds', () => {
417
- const result = aggregations(listingDetailMappings)
418
- .dateHistogram('over_time', 'listed_date', {
419
- interval: 'day',
420
- extended_bounds: {
421
- min: '2024-01-01',
422
- max: '2024-12-31'
423
- }
424
- })
425
- .build();
426
- expect(result.over_time.date_histogram.extended_bounds).toStrictEqual({
427
- min: '2024-01-01',
428
- max: '2024-12-31'
429
- });
430
- });
431
- it('should create dateHistogram with time_zone', () => {
432
- const result = aggregations(listingDetailMappings)
433
- .dateHistogram('over_time', 'listed_date', {
434
- interval: 'day',
435
- time_zone: 'America/New_York'
436
- })
437
- .build();
438
- expect(result.over_time.date_histogram.time_zone).toBe('America/New_York');
439
- });
440
- it('should create dateHistogram with order', () => {
441
- const result = aggregations(listingDetailMappings)
442
- .dateHistogram('over_time', 'listed_date', {
443
- interval: 'month',
444
- order: { _key: 'desc' }
445
- })
446
- .build();
447
- expect(result.over_time.date_histogram.order).toStrictEqual({
448
- _key: 'desc'
449
- });
450
- });
451
- });
452
- describe('Histogram aggregation options', () => {
453
- it('should create histogram with min_doc_count', () => {
454
- const result = aggregations(listingDetailMappings)
455
- .histogram('price_buckets', 'list_price', {
456
- interval: 100,
457
- min_doc_count: 1
458
- })
459
- .build();
460
- expect(result.price_buckets.histogram.min_doc_count).toBe(1);
461
- });
462
- it('should create histogram with extended_bounds', () => {
463
- const result = aggregations(listingDetailMappings)
464
- .histogram('price_buckets', 'list_price', {
465
- interval: 50,
466
- extended_bounds: { min: 0, max: 1000 }
467
- })
468
- .build();
469
- expect(result.price_buckets.histogram.extended_bounds).toStrictEqual({
470
- min: 0,
471
- max: 1000
472
- });
473
- });
474
- });
475
- describe('Metric aggregation options', () => {
476
- it('should create avg with missing value', () => {
477
- const result = aggregations(listingDetailMappings).avg('avg_price', 'list_price', { missing: 0 }).build();
478
- expect(result).toMatchInlineSnapshot(`
479
- {
480
- "avg_price": {
481
- "avg": {
482
- "field": "list_price",
483
- "missing": 0,
484
- },
485
- },
486
- }
487
- `);
488
- });
489
- it('should create sum with missing value', () => {
490
- const result = aggregations(listingDetailMappings).sum('total_price', 'list_price', { missing: 0 }).build();
491
- expect(result.total_price.sum.missing).toBe(0);
492
- });
493
- it('should create min with missing value', () => {
494
- const result = aggregations(listingDetailMappings).min('min_price', 'list_price', { missing: 9999 }).build();
495
- expect(result.min_price.min.missing).toBe(9999);
496
- });
497
- it('should create max with missing value', () => {
498
- const result = aggregations(listingDetailMappings).max('max_price', 'list_price', { missing: 0 }).build();
499
- expect(result.max_price.max.missing).toBe(0);
500
- });
501
- it('should create cardinality without options', () => {
502
- const result = aggregations(listingDetailMappings).cardinality('unique_categories', 'property_class').build();
503
- expect(result).toMatchInlineSnapshot(`
504
- {
505
- "unique_categories": {
506
- "cardinality": {
507
- "field": "property_class",
508
- },
509
- },
510
- }
511
- `);
512
- });
513
- it('should create percentiles with keyed option', () => {
514
- const result = aggregations(listingDetailMappings)
515
- .percentiles('price_percentiles', 'list_price', {
516
- percents: [25, 50, 75, 95, 99],
517
- keyed: true
518
- })
519
- .build();
520
- expect(result.price_percentiles.percentiles.keyed).toBe(true);
521
- expect(result.price_percentiles.percentiles.percents).toStrictEqual([25, 50, 75, 95, 99]);
522
- });
523
- it('should create stats with missing value', () => {
524
- const result = aggregations(listingDetailMappings).stats('price_stats', 'list_price', { missing: 0 }).build();
525
- expect(result.price_stats.stats.missing).toBe(0);
526
- });
527
- it('should create valueCount with missing value', () => {
528
- const result = aggregations(listingDetailMappings)
529
- .valueCount('rating_count', 'cap_rate', { missing: 0 })
530
- .build();
531
- expect(result.rating_count.value_count.missing).toBe(0);
532
- });
533
- });
534
- describe('Sub-aggregation patterns', () => {
535
- it('should add sub-agg to dateHistogram', () => {
536
- const result = aggregations(listingDetailMappings)
537
- .dateHistogram('by_month', 'listed_date', { interval: 'month' })
538
- .subAgg((sub) => sub.sum('monthly_revenue', 'list_price').avg('avg_rating', 'cap_rate'))
539
- .build();
540
- expect(result).toMatchObject({
541
- by_month: {
542
- date_histogram: { field: 'listed_date', interval: 'month' },
543
- aggs: {
544
- monthly_revenue: { sum: { field: 'list_price' } },
545
- avg_rating: { avg: { field: 'cap_rate' } }
546
- }
547
- }
548
- });
549
- });
550
- it('should add sub-agg to range aggregation', () => {
551
- const result = aggregations(listingDetailMappings)
552
- .range('price_ranges', 'list_price', {
553
- ranges: [{ to: 50 }, { from: 50, to: 100 }, { from: 100 }]
554
- })
555
- .subAgg((sub) => sub.avg('avg_rating', 'cap_rate'))
556
- .build();
557
- expect(result).toMatchObject({
558
- price_ranges: {
559
- range: {
560
- field: 'list_price',
561
- ranges: [{ to: 50 }, { from: 50, to: 100 }, { from: 100 }]
562
- },
563
- aggs: {
564
- avg_rating: { avg: { field: 'cap_rate' } }
565
- }
566
- }
567
- });
568
- });
569
- it('should add sub-agg to histogram aggregation', () => {
570
- const result = aggregations(listingDetailMappings)
571
- .histogram('price_histogram', 'list_price', { interval: 25 })
572
- .subAgg((sub) => sub.cardinality('unique_categories', 'property_class'))
573
- .build();
574
- expect(result).toMatchObject({
575
- price_histogram: {
576
- histogram: { field: 'list_price', interval: 25 },
577
- aggs: {
578
- unique_categories: { cardinality: { field: 'property_class' } }
579
- }
580
- }
581
- });
582
- });
583
- it('should create multiple sibling sub-aggregations', () => {
584
- const result = aggregations(listingDetailMappings)
585
- .terms('by_property_class', 'property_class')
586
- .subAgg((sub) => sub
587
- .avg('avg_price', 'list_price')
588
- .min('min_price', 'list_price')
589
- .max('max_price', 'list_price')
590
- .sum('total_revenue', 'list_price')
591
- .stats('price_stats', 'list_price'))
592
- .build();
593
- expect(result).toMatchObject({
594
- by_property_class: {
595
- terms: { field: 'property_class' },
596
- aggs: {
597
- avg_price: { avg: { field: 'list_price' } },
598
- min_price: { min: { field: 'list_price' } },
599
- max_price: { max: { field: 'list_price' } },
600
- total_revenue: { sum: { field: 'list_price' } },
601
- price_stats: { stats: { field: 'list_price' } }
602
- }
603
- }
604
- });
605
- });
606
- it('should create multiple bucket aggregations at same level', () => {
607
- const result = aggregations(listingDetailMappings)
608
- .terms('by_property_class', 'property_class', { size: 10 })
609
- .terms('by_title', 'title', { size: 5 })
610
- .dateHistogram('by_date', 'listed_date', { interval: 'week' })
611
- .build();
612
- expect(result).toMatchObject({
613
- by_property_class: { terms: { field: 'property_class', size: 10 } },
614
- by_title: { terms: { field: 'title', size: 5 } },
615
- by_date: {
616
- date_histogram: { field: 'listed_date', interval: 'week' }
617
- }
618
- });
619
- });
620
- });
621
- });
622
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=bulk.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bulk.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/bulk.test.ts"],"names":[],"mappings":""}