mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
fix grouping and query builder unit tests
This commit is contained in:
parent
6d00c9f1f4
commit
aa5bb4f39d
3 changed files with 5 additions and 6 deletions
|
@ -94,7 +94,7 @@ describe('group selector', () => {
|
|||
it('groupByField script should contain logic which gets all values of groupByField', () => {
|
||||
const scriptResponse = {
|
||||
source:
|
||||
"if (doc[params['selectedGroup']].size()==0) { emit(params['uniqueValue']) } else { emit(doc[params['selectedGroup']].join(params['uniqueValue']))}",
|
||||
"if (doc[params['selectedGroup']].size()==0 || doc[params['selectedGroup']].size() > 100 ) { emit(params['uniqueValue']) } else { emit(doc[params['selectedGroup']].join(params['uniqueValue']))}",
|
||||
params: {
|
||||
selectedGroup: 'resource.name',
|
||||
uniqueValue: 'whatAGreatAndUniqueValue',
|
||||
|
@ -113,7 +113,7 @@ describe('group selector', () => {
|
|||
|
||||
const scriptResponse = {
|
||||
source:
|
||||
"if (doc[params['selectedGroup']].size()==0) { emit(params['uniqueValue']) } else { for (def id : doc[params['selectedGroup']]) { emit(id) }}",
|
||||
"if (doc[params['selectedGroup']].size()==0 || doc[params['selectedGroup']].size() > 100 ) { emit(params['uniqueValue']) } else { int i = 0; for (def id : doc[params['selectedGroup']]) { if (i++ >= 100) break; emit(id)}}",
|
||||
params: {
|
||||
selectedGroup: groupByField,
|
||||
uniqueValue: 'whatAGreatAndUniqueValue',
|
||||
|
|
|
@ -66,9 +66,8 @@ export const getGroupingQuery = ({
|
|||
type: 'keyword',
|
||||
script: {
|
||||
source:
|
||||
// when size()==0, emits a uniqueValue as the value to represent this group
|
||||
// when size()==0 or size() > MAX_RUNTIME_FIELD_SIZE, emits a uniqueValue as the value to represent this group
|
||||
`if (doc[params['selectedGroup']].size()==0 || doc[params['selectedGroup']].size() > ${MAX_RUNTIME_FIELD_SIZE} ) { emit(params['uniqueValue']) }` +
|
||||
// `if (doc[params['selectedGroup']].size()==0 ) { emit(params['uniqueValue']) }` +
|
||||
/*
|
||||
* condition to decide between joining values or flattening based on shouldFlattenMultiValueField and groupByField parameters
|
||||
* if shouldFlattenMultiValueField is true, and the selectedGroup field is an array, then emit each value in the array
|
||||
|
@ -82,7 +81,7 @@ export const getGroupingQuery = ({
|
|||
* We will format into a proper array in parseGroupingQuery
|
||||
*/
|
||||
(shouldFlattenMultiValueField
|
||||
? ` else { int i = 0; for (def id : doc['vulnerability.id']) { if (i++ >= ${MAX_RUNTIME_FIELD_SIZE}) break; emit(id)}}`
|
||||
? ` else { int i = 0; for (def id : doc[params['selectedGroup']]) { if (i++ >= ${MAX_RUNTIME_FIELD_SIZE}) break; emit(id)}}`
|
||||
: " else { emit(doc[params['selectedGroup']].join(params['uniqueValue']))}"),
|
||||
params: {
|
||||
selectedGroup: groupByField,
|
||||
|
|
|
@ -97,7 +97,7 @@ export const getQuery = (
|
|||
type: 'keyword',
|
||||
script: {
|
||||
source:
|
||||
"if (doc[params['selectedGroup']].size()==0) { emit(params['uniqueValue']) } else { emit(doc[params['selectedGroup']].join(params['uniqueValue']))}",
|
||||
"if (doc[params['selectedGroup']].size()==0 || doc[params['selectedGroup']].size() > 100 ) { emit(params['uniqueValue']) } else { emit(doc[params['selectedGroup']].join(params['uniqueValue']))}",
|
||||
params: {
|
||||
selectedGroup,
|
||||
uniqueValue,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue