@blaze-cms/react-page-builder 0.133.0-admin-updates.0 → 0.133.0-admin-updates.1
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/CHANGELOG.md +11 -0
- package/lib/helpers/build-raw-query.js +7 -6
- package/lib/helpers/build-raw-query.js.map +1 -1
- package/lib-es/helpers/build-raw-query.js +5 -4
- package/lib-es/helpers/build-raw-query.js.map +1 -1
- package/package.json +2 -2
- package/src/helpers/build-raw-query.js +5 -1
- package/tests/unit/src/helpers/build-raw-query.test.js +70 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.133.0-admin-updates.1](https://github.com/thebyte9/blaze/compare/v0.133.0-admin-updates.0...v0.133.0-admin-updates.1) (2023-09-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* handle search filters where custom sort applied ([#4039](https://github.com/thebyte9/blaze/issues/4039)) ([857dd75](https://github.com/thebyte9/blaze/commit/857dd75ca26812dc2db29d634800727c32dce502))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.133.0-admin-updates.0](https://github.com/thebyte9/blaze/compare/v0.132.0...v0.133.0-admin-updates.0) (2023-08-25)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -47,13 +47,14 @@ var buildRawQuery = function buildRawQuery(_ref) {
|
|
|
47
47
|
isAZ = _ref2.isAZ,
|
|
48
48
|
_ref2$sortProperties = _ref2.sortProperties,
|
|
49
49
|
sortProperties = _ref2$sortProperties === void 0 ? [] : _ref2$sortProperties;
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
_sortProperties$2 = _sortProperties$ === void 0 ? {
|
|
50
|
+
var sortPropertyToUse = isAZ && sortProperties[0] && sortProperties[0].isScore ? 1 : 0;
|
|
51
|
+
var _ref3 = sortProperties[sortPropertyToUse] || {
|
|
53
52
|
propsToDisplay: []
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
},
|
|
54
|
+
_ref3$propsToDisplay = _ref3.propsToDisplay,
|
|
55
|
+
_ref3$propsToDisplay2 = _ref3$propsToDisplay === void 0 ? [] : _ref3$propsToDisplay,
|
|
56
|
+
_ref3$propsToDisplay3 = (0, _slicedToArray2["default"])(_ref3$propsToDisplay2, 1),
|
|
57
|
+
azSortProp = _ref3$propsToDisplay3[0];
|
|
57
58
|
var azSortProperty = azSortProp || _constants.AZ_DEFAULT_PROP;
|
|
58
59
|
var searchValuesTextCheckboxSelectJoined = operator === _constants.AND_OPERATOR ? [].concat((0, _toConsumableArray2["default"])(searchValuesText), (0, _toConsumableArray2["default"])(searchValuesCheckboxSelectRange)) : [];
|
|
59
60
|
var searchValuesTextCheckboxOr = searchValuesText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-raw-query.js","names":["_buildRawQueryBase","_interopRequireDefault","require","_getItemsToDisplayIds","_getExtraAzBits","_buildAzFilter","_constants","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","buildRawQuery","_ref","docType","operator","searchValues","filterData","id","itemsToDisplay","shouldApplySort","azOptions","searchValuesText","searchValuesCheckboxSelectRange","searchValuesCheckboxOr","filterValues","filterOperator","relations","stringProps","azFilter","_ref2","isAZ","_ref2$sortProperties","sortProperties","
|
|
1
|
+
{"version":3,"file":"build-raw-query.js","names":["_buildRawQueryBase","_interopRequireDefault","require","_getItemsToDisplayIds","_getExtraAzBits","_buildAzFilter","_constants","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","buildRawQuery","_ref","docType","operator","searchValues","filterData","id","itemsToDisplay","shouldApplySort","azOptions","searchValuesText","searchValuesCheckboxSelectRange","searchValuesCheckboxOr","filterValues","filterOperator","relations","stringProps","azFilter","_ref2","isAZ","_ref2$sortProperties","sortProperties","sortPropertyToUse","isScore","_ref3","propsToDisplay","_ref3$propsToDisplay","_ref3$propsToDisplay2","_ref3$propsToDisplay3","_slicedToArray2","azSortProp","azSortProperty","AZ_DEFAULT_PROP","searchValuesTextCheckboxSelectJoined","AND_OPERATOR","concat","_toConsumableArray2","searchValuesTextCheckboxOr","finalValue","finalValueWithCheckboxOrValues","must","bool","should","finalValueIfNoCheckboxOrValues","mustValues","buildAzFilter","query","buildRawQueryBase","azQueryBits","getExtraAzBits","itemsToDisplayIds","getItemsToDisplayIds","ids","values","sort","_script","type","script","lang","source","params","sortOrder","order","_default","exports"],"sources":["../../src/helpers/build-raw-query.js"],"sourcesContent":["import buildRawQueryBase from './build-raw-query-base';\nimport getItemsToDisplayIds from './get-items-to-display-ids';\nimport getExtraAzBits from './get-extra-az-bits';\nimport buildAzFilter from './build-az-filter';\nimport { AND_OPERATOR, AZ_DEFAULT_PROP } from '../constants';\n\nconst buildRawQuery = ({\n docType,\n operator,\n searchValues,\n filterData,\n id,\n itemsToDisplay,\n shouldApplySort,\n azOptions\n}) => {\n const {\n searchValuesText,\n searchValuesCheckboxSelectRange,\n searchValuesCheckboxOr\n } = searchValues;\n const { filterValues, filterOperator, relations, stringProps, azFilter } = filterData;\n\n const { isAZ, sortProperties = [] } = azOptions || {};\n const sortPropertyToUse = isAZ && sortProperties[0] && sortProperties[0].isScore ? 1 : 0;\n const { propsToDisplay: [azSortProp] = [] } = sortProperties[sortPropertyToUse] || {\n propsToDisplay: []\n };\n const azSortProperty = azSortProp || AZ_DEFAULT_PROP;\n\n const searchValuesTextCheckboxSelectJoined =\n operator === AND_OPERATOR ? [...searchValuesText, ...searchValuesCheckboxSelectRange] : [];\n let searchValuesTextCheckboxOr = searchValuesText;\n if (searchValuesCheckboxOr.length) {\n searchValuesTextCheckboxOr = [...searchValuesText, ...searchValuesCheckboxOr];\n }\n\n let finalValue;\n\n if (searchValuesTextCheckboxSelectJoined.length) {\n const finalValueWithCheckboxOrValues = {\n must: [...searchValuesTextCheckboxSelectJoined, { bool: { should: searchValuesCheckboxOr } }]\n };\n const finalValueIfNoCheckboxOrValues = { must: searchValuesTextCheckboxSelectJoined };\n finalValue = searchValuesCheckboxOr.length\n ? finalValueWithCheckboxOrValues\n : finalValueIfNoCheckboxOrValues;\n } else {\n finalValue = {\n must: [...searchValuesCheckboxSelectRange, { bool: { should: searchValuesTextCheckboxOr } }]\n };\n }\n const mustValues = [\n {\n bool: finalValue\n }\n ];\n\n buildAzFilter(azFilter, mustValues, azSortProperty);\n\n const query = {\n bool: {\n must: mustValues,\n ...buildRawQueryBase({ docType, id, filterValues, filterOperator, relations, stringProps })\n }\n };\n const azQueryBits = getExtraAzBits({ ...azOptions, azSortProperty, azFilter });\n\n if (itemsToDisplay && itemsToDisplay.length) {\n const itemsToDisplayIds = getItemsToDisplayIds(itemsToDisplay);\n\n query.bool.must.push({ ids: { values: itemsToDisplayIds } });\n if (shouldApplySort) {\n return {\n query,\n sort: {\n _script: {\n type: 'number',\n script: {\n lang: 'painless',\n source:\n \"!doc['id.keyword'].empty ? params.sortOrder.indexOf(doc['id.keyword'].value) : 0\",\n params: {\n sortOrder: itemsToDisplayIds\n }\n },\n order: 'asc'\n }\n },\n ...azQueryBits\n };\n }\n }\n\n return isAZ\n ? {\n query,\n ...azQueryBits\n }\n : query;\n};\n\nexport default buildRawQuery;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,eAAA,GAAAH,sBAAA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S,EAATA,SAAS;MAAEC,WAAW,EAAXA;IAAY,CAAC,CAAC;EAE/F,CAAC;EACD,IAAMgC,WAAW,GAAG,IAAAC,0BAAc,EAAAzD,aAAA,CAAAA,aAAA,KAAMiB,SAAS;IAAEsB,cAAc,EAAdA,cAAc;IAAEd,QAAQ,EAARA;EAAQ,EAAE,CAAC;EAE9E,IAAIV,cAAc,IAAIA,cAAc,CAACb,MAAM,EAAE;IAC3C,IAAMwD,iBAAiB,GAAG,IAAAC,gCAAoB,EAAC5C,cAAc,CAAC;IAE9DuC,KAAK,CAACL,IAAI,CAACD,IAAI,CAAClD,IAAI,CAAC;MAAE8D,GAAG,EAAE;QAAEC,MAAM,EAAEH;MAAkB;IAAE,CAAC,CAAC;IAC5D,IAAI1C,eAAe,EAAE;MACnB,OAAAhB,aAAA;QACEsD,KAAK,EAALA,KAAK;QACLQ,IAAI,EAAE;UACJC,OAAO,EAAE;YACPC,IAAI,EAAE,QAAQ;YACdC,MAAM,EAAE;cACNC,IAAI,EAAE,UAAU;cAChBC,MAAM,EACJ,kFAAkF;cACpFC,MAAM,EAAE;gBACNC,SAAS,EAAEX;cACb;YACF,CAAC;YACDY,KAAK,EAAE;UACT;QACF;MAAC,GACEd,WAAW;IAElB;EACF;EAEA,OAAO7B,IAAI,GAAA3B,aAAA;IAELsD,KAAK,EAALA;EAAK,GACFE,WAAW,IAEhBF,KAAK;AACX,CAAC;AAAC,IAAAiB,QAAA,GAEa/D,aAAa;AAAAgE,OAAA,cAAAD,QAAA"}
|
|
@@ -32,11 +32,12 @@ const buildRawQuery = ({
|
|
|
32
32
|
isAZ,
|
|
33
33
|
sortProperties = []
|
|
34
34
|
} = azOptions || {};
|
|
35
|
-
const [
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const sortPropertyToUse = isAZ && sortProperties[0] && sortProperties[0].isScore ? 1 : 0;
|
|
36
|
+
const {
|
|
37
|
+
propsToDisplay: [azSortProp] = []
|
|
38
|
+
} = sortProperties[sortPropertyToUse] || {
|
|
38
39
|
propsToDisplay: []
|
|
39
|
-
}
|
|
40
|
+
};
|
|
40
41
|
const azSortProperty = azSortProp || AZ_DEFAULT_PROP;
|
|
41
42
|
const searchValuesTextCheckboxSelectJoined = operator === AND_OPERATOR ? [...searchValuesText, ...searchValuesCheckboxSelectRange] : [];
|
|
42
43
|
let searchValuesTextCheckboxOr = searchValuesText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-raw-query.js","names":["buildRawQueryBase","getItemsToDisplayIds","getExtraAzBits","buildAzFilter","AND_OPERATOR","AZ_DEFAULT_PROP","buildRawQuery","docType","operator","searchValues","filterData","id","itemsToDisplay","shouldApplySort","azOptions","searchValuesText","searchValuesCheckboxSelectRange","searchValuesCheckboxOr","filterValues","filterOperator","relations","stringProps","azFilter","isAZ","sortProperties","propsToDisplay","azSortProp","azSortProperty","searchValuesTextCheckboxSelectJoined","searchValuesTextCheckboxOr","length","finalValue","finalValueWithCheckboxOrValues","must","bool","should","finalValueIfNoCheckboxOrValues","mustValues","query","_objectSpread","azQueryBits","itemsToDisplayIds","push","ids","values","sort","_script","type","script","lang","source","params","sortOrder","order"],"sources":["../../src/helpers/build-raw-query.js"],"sourcesContent":["import buildRawQueryBase from './build-raw-query-base';\nimport getItemsToDisplayIds from './get-items-to-display-ids';\nimport getExtraAzBits from './get-extra-az-bits';\nimport buildAzFilter from './build-az-filter';\nimport { AND_OPERATOR, AZ_DEFAULT_PROP } from '../constants';\n\nconst buildRawQuery = ({\n docType,\n operator,\n searchValues,\n filterData,\n id,\n itemsToDisplay,\n shouldApplySort,\n azOptions\n}) => {\n const {\n searchValuesText,\n searchValuesCheckboxSelectRange,\n searchValuesCheckboxOr\n } = searchValues;\n const { filterValues, filterOperator, relations, stringProps, azFilter } = filterData;\n const { isAZ, sortProperties = [] } = azOptions || {};\n const [{ propsToDisplay: [azSortProp] } = {
|
|
1
|
+
{"version":3,"file":"build-raw-query.js","names":["buildRawQueryBase","getItemsToDisplayIds","getExtraAzBits","buildAzFilter","AND_OPERATOR","AZ_DEFAULT_PROP","buildRawQuery","docType","operator","searchValues","filterData","id","itemsToDisplay","shouldApplySort","azOptions","searchValuesText","searchValuesCheckboxSelectRange","searchValuesCheckboxOr","filterValues","filterOperator","relations","stringProps","azFilter","isAZ","sortProperties","sortPropertyToUse","isScore","propsToDisplay","azSortProp","azSortProperty","searchValuesTextCheckboxSelectJoined","searchValuesTextCheckboxOr","length","finalValue","finalValueWithCheckboxOrValues","must","bool","should","finalValueIfNoCheckboxOrValues","mustValues","query","_objectSpread","azQueryBits","itemsToDisplayIds","push","ids","values","sort","_script","type","script","lang","source","params","sortOrder","order"],"sources":["../../src/helpers/build-raw-query.js"],"sourcesContent":["import buildRawQueryBase from './build-raw-query-base';\nimport getItemsToDisplayIds from './get-items-to-display-ids';\nimport getExtraAzBits from './get-extra-az-bits';\nimport buildAzFilter from './build-az-filter';\nimport { AND_OPERATOR, AZ_DEFAULT_PROP } from '../constants';\n\nconst buildRawQuery = ({\n docType,\n operator,\n searchValues,\n filterData,\n id,\n itemsToDisplay,\n shouldApplySort,\n azOptions\n}) => {\n const {\n searchValuesText,\n searchValuesCheckboxSelectRange,\n searchValuesCheckboxOr\n } = searchValues;\n const { filterValues, filterOperator, relations, stringProps, azFilter } = filterData;\n\n const { isAZ, sortProperties = [] } = azOptions || {};\n const sortPropertyToUse = isAZ && sortProperties[0] && sortProperties[0].isScore ? 1 : 0;\n const { propsToDisplay: [azSortProp] = [] } = sortProperties[sortPropertyToUse] || {\n propsToDisplay: []\n };\n const azSortProperty = azSortProp || AZ_DEFAULT_PROP;\n\n const searchValuesTextCheckboxSelectJoined =\n operator === AND_OPERATOR ? [...searchValuesText, ...searchValuesCheckboxSelectRange] : [];\n let searchValuesTextCheckboxOr = searchValuesText;\n if (searchValuesCheckboxOr.length) {\n searchValuesTextCheckboxOr = [...searchValuesText, ...searchValuesCheckboxOr];\n }\n\n let finalValue;\n\n if (searchValuesTextCheckboxSelectJoined.length) {\n const finalValueWithCheckboxOrValues = {\n must: [...searchValuesTextCheckboxSelectJoined, { bool: { should: searchValuesCheckboxOr } }]\n };\n const finalValueIfNoCheckboxOrValues = { must: searchValuesTextCheckboxSelectJoined };\n finalValue = searchValuesCheckboxOr.length\n ? finalValueWithCheckboxOrValues\n : finalValueIfNoCheckboxOrValues;\n } else {\n finalValue = {\n must: [...searchValuesCheckboxSelectRange, { bool: { should: searchValuesTextCheckboxOr } }]\n };\n }\n const mustValues = [\n {\n bool: finalValue\n }\n ];\n\n buildAzFilter(azFilter, mustValues, azSortProperty);\n\n const query = {\n bool: {\n must: mustValues,\n ...buildRawQueryBase({ docType, id, filterValues, filterOperator, relations, stringProps })\n }\n };\n const azQueryBits = getExtraAzBits({ ...azOptions, azSortProperty, azFilter });\n\n if (itemsToDisplay && itemsToDisplay.length) {\n const itemsToDisplayIds = getItemsToDisplayIds(itemsToDisplay);\n\n query.bool.must.push({ ids: { values: itemsToDisplayIds } });\n if (shouldApplySort) {\n return {\n query,\n sort: {\n _script: {\n type: 'number',\n script: {\n lang: 'painless',\n source:\n \"!doc['id.keyword'].empty ? params.sortOrder.indexOf(doc['id.keyword'].value) : 0\",\n params: {\n sortOrder: itemsToDisplayIds\n }\n },\n order: 'asc'\n }\n },\n ...azQueryBits\n };\n }\n }\n\n return isAZ\n ? {\n query,\n ...azQueryBits\n }\n : query;\n};\n\nexport default buildRawQuery;\n"],"mappings":";;;AAAA,OAAOA,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,oBAAoB,MAAM,4BAA4B;AAC7D,OAAOC,cAAc,MAAM,qBAAqB;AAChD,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,SAASC,YAAY,EAAEC,eAAe,QAAQ,cAAc;AAE5D,MAAMC,aAAa,GAAGA,CAAC;EACrBC,OAAO;EACPC,QAAQ;EACRC,YAAY;EACZC,UAAU;EACVC,EAAE;EACFC,cAAc;EACdC,eAAe;EACfC;AACF,CAAC,KAAK;EACJ,MAAM;I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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.133.0-admin-updates.
|
|
3
|
+
"version": "0.133.0-admin-updates.1",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"lib/*",
|
|
90
90
|
"lib-es/*"
|
|
91
91
|
],
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "88859485b7c7c151accd57ce8ab8b8d2c8c1b6da"
|
|
93
93
|
}
|
|
@@ -20,8 +20,12 @@ const buildRawQuery = ({
|
|
|
20
20
|
searchValuesCheckboxOr
|
|
21
21
|
} = searchValues;
|
|
22
22
|
const { filterValues, filterOperator, relations, stringProps, azFilter } = filterData;
|
|
23
|
+
|
|
23
24
|
const { isAZ, sortProperties = [] } = azOptions || {};
|
|
24
|
-
const
|
|
25
|
+
const sortPropertyToUse = isAZ && sortProperties[0] && sortProperties[0].isScore ? 1 : 0;
|
|
26
|
+
const { propsToDisplay: [azSortProp] = [] } = sortProperties[sortPropertyToUse] || {
|
|
27
|
+
propsToDisplay: []
|
|
28
|
+
};
|
|
25
29
|
const azSortProperty = azSortProp || AZ_DEFAULT_PROP;
|
|
26
30
|
|
|
27
31
|
const searchValuesTextCheckboxSelectJoined =
|
|
@@ -32,6 +32,7 @@ const filterData = {
|
|
|
32
32
|
relations: [],
|
|
33
33
|
stringProps: []
|
|
34
34
|
};
|
|
35
|
+
const customProperty = 'lastname';
|
|
35
36
|
|
|
36
37
|
describe('build raw query', () => {
|
|
37
38
|
const {
|
|
@@ -365,7 +366,6 @@ describe('build raw query', () => {
|
|
|
365
366
|
});
|
|
366
367
|
|
|
367
368
|
it('should return query with aggs if requested using custom az param', () => {
|
|
368
|
-
const customProperty = 'lastname';
|
|
369
369
|
const queryWithAggs = buildRawQuery({
|
|
370
370
|
docType,
|
|
371
371
|
operator,
|
|
@@ -387,4 +387,73 @@ describe('build raw query', () => {
|
|
|
387
387
|
|
|
388
388
|
expect(JSON.stringify(queryWithAggs)).toContain(`${customProperty}.keyword`);
|
|
389
389
|
});
|
|
390
|
+
|
|
391
|
+
it('should handle filters with search where custom sort is also set', () => {
|
|
392
|
+
const queryWithAggs = buildRawQuery({
|
|
393
|
+
docType,
|
|
394
|
+
operator,
|
|
395
|
+
searchValues: {
|
|
396
|
+
searchValuesText,
|
|
397
|
+
searchValuesCheckboxSelectRange,
|
|
398
|
+
searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
|
|
399
|
+
},
|
|
400
|
+
filterData,
|
|
401
|
+
id,
|
|
402
|
+
itemsToDisplay: [],
|
|
403
|
+
shouldApplySort: true,
|
|
404
|
+
azOptions: {
|
|
405
|
+
shouldReturnAggs: false,
|
|
406
|
+
isAZ: false,
|
|
407
|
+
sortProperties: [{ isScore: true }]
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
expect(JSON.stringify(queryWithAggs)).not.toContain('sort');
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it('should handle search filters with az listing using custom sort', () => {
|
|
415
|
+
const queryWithAggs = buildRawQuery({
|
|
416
|
+
docType,
|
|
417
|
+
operator,
|
|
418
|
+
searchValues: {
|
|
419
|
+
searchValuesText,
|
|
420
|
+
searchValuesCheckboxSelectRange,
|
|
421
|
+
searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
|
|
422
|
+
},
|
|
423
|
+
filterData,
|
|
424
|
+
id,
|
|
425
|
+
itemsToDisplay: [],
|
|
426
|
+
shouldApplySort: true,
|
|
427
|
+
azOptions: {
|
|
428
|
+
shouldReturnAggs: true,
|
|
429
|
+
isAZ: true,
|
|
430
|
+
sortProperties: [{ isScore: true }, { propsToDisplay: [customProperty] }]
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
expect(JSON.stringify(queryWithAggs)).toContain(`${customProperty}.keyword`);
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it('should handle search filters with az listing using custom default', () => {
|
|
438
|
+
const queryWithAggs = buildRawQuery({
|
|
439
|
+
docType,
|
|
440
|
+
operator,
|
|
441
|
+
searchValues: {
|
|
442
|
+
searchValuesText,
|
|
443
|
+
searchValuesCheckboxSelectRange,
|
|
444
|
+
searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
|
|
445
|
+
},
|
|
446
|
+
filterData,
|
|
447
|
+
id,
|
|
448
|
+
itemsToDisplay: [],
|
|
449
|
+
shouldApplySort: true,
|
|
450
|
+
azOptions: {
|
|
451
|
+
shouldReturnAggs: true,
|
|
452
|
+
isAZ: true,
|
|
453
|
+
sortProperties: [{ isScore: true }]
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
expect(queryWithAggs).toEqual(RAW_QUERY_WITH_AGGS);
|
|
458
|
+
});
|
|
390
459
|
});
|