1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.DateSearchFacet = exports.NumericSearchFacet = exports.TermSearchFacet = exports.SearchFacet = void 0;
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | class SearchFacet {
|
11 | constructor(data) {
|
12 | if (!data) {
|
13 | data = {};
|
14 | }
|
15 | this._data = data;
|
16 | }
|
17 | toJSON() {
|
18 | return this._data;
|
19 | }
|
20 | static term(field, size) {
|
21 | return new TermSearchFacet(field, size);
|
22 | }
|
23 | static numeric(field, size) {
|
24 | return new NumericSearchFacet(field, size);
|
25 | }
|
26 | static date(field, size) {
|
27 | return new DateSearchFacet(field, size);
|
28 | }
|
29 | }
|
30 | exports.SearchFacet = SearchFacet;
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | class TermSearchFacet extends SearchFacet {
|
37 | |
38 |
|
39 |
|
40 | constructor(field, size) {
|
41 | super({
|
42 | field: field,
|
43 | size: size,
|
44 | });
|
45 | }
|
46 | }
|
47 | exports.TermSearchFacet = TermSearchFacet;
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | class NumericSearchFacet extends SearchFacet {
|
54 | |
55 |
|
56 |
|
57 | constructor(field, size) {
|
58 | super({
|
59 | field: field,
|
60 | size: size,
|
61 | numeric_ranges: [],
|
62 | });
|
63 | }
|
64 | addRange(name, min, max) {
|
65 | this._data.numeric_ranges.push({
|
66 | name: name,
|
67 | min: min,
|
68 | max: max,
|
69 | });
|
70 | return this;
|
71 | }
|
72 | }
|
73 | exports.NumericSearchFacet = NumericSearchFacet;
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | class DateSearchFacet extends SearchFacet {
|
80 | |
81 |
|
82 |
|
83 | constructor(field, size) {
|
84 | super({
|
85 | field: field,
|
86 | size: size,
|
87 | date_ranges: [],
|
88 | });
|
89 | }
|
90 | addRange(name, start, end) {
|
91 | this._data.date_ranges.push({
|
92 | name: name,
|
93 | start: start,
|
94 | end: end,
|
95 | });
|
96 | return this;
|
97 | }
|
98 | }
|
99 | exports.DateSearchFacet = DateSearchFacet;
|