-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
116 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
x-pack/packages/ml/query_utils/src/build_base_filter_criteria.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { buildBaseFilterCriteria } from './build_base_filter_criteria'; | ||
|
||
describe('buildBaseFilterCriteria', () => { | ||
const earliestMs = 1483228800000; // 1 Jan 2017 00:00:00 | ||
const latestMs = 1485907199000; // 31 Jan 2017 23:59:59 | ||
const query = { | ||
query_string: { | ||
query: 'region:sa-east-1', | ||
analyze_wildcard: true, | ||
default_field: '*', | ||
}, | ||
}; | ||
|
||
test('returns correct criteria for time range', () => { | ||
expect(buildBaseFilterCriteria('timestamp', earliestMs, latestMs)).toEqual([ | ||
{ | ||
range: { | ||
timestamp: { | ||
gte: earliestMs, | ||
lte: latestMs, | ||
format: 'epoch_millis', | ||
}, | ||
}, | ||
}, | ||
]); | ||
}); | ||
|
||
test('returns correct criteria for time range and query', () => { | ||
expect(buildBaseFilterCriteria('timestamp', earliestMs, latestMs, query)).toEqual([ | ||
{ | ||
range: { | ||
timestamp: { | ||
gte: earliestMs, | ||
lte: latestMs, | ||
format: 'epoch_millis', | ||
}, | ||
}, | ||
}, | ||
query, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
x-pack/packages/ml/query_utils/src/get_safe_aggregation_name.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getSafeAggregationName } from './get_safe_aggregation_name'; | ||
|
||
describe('getSafeAggregationName', () => { | ||
test('"foo" should be "foo"', () => { | ||
expect(getSafeAggregationName('foo', 0)).toBe('foo'); | ||
}); | ||
test('"foo.bar" should be "foo.bar"', () => { | ||
expect(getSafeAggregationName('foo.bar', 0)).toBe('foo.bar'); | ||
}); | ||
test('"foo&bar" should be "field_0"', () => { | ||
expect(getSafeAggregationName('foo&bar', 0)).toBe('field_0'); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
x-pack/packages/ml/query_utils/src/get_safe_aggregation_name.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
// Returns a name which is safe to use in elasticsearch aggregations for the supplied | ||
// field name. Aggregation names must be alpha-numeric and can only contain '_' and '-' characters, | ||
// so if the supplied field names contains disallowed characters, the provided index | ||
// identifier is used to return a safe 'dummy' name in the format 'field_index' e.g. field_0, field_1 | ||
export function getSafeAggregationName(fieldName: string, index: number): string { | ||
return fieldName.match(/^[a-zA-Z0-9-_.]+$/) ? fieldName : `field_${index}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,6 @@ | |
], | ||
"kbn_references": [ | ||
"@kbn/ml-is-populated-object", | ||
"@kbn/es-query", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
x-pack/plugins/apm/server/routes/correlations/utils/field_stats_utils.ts
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
x-pack/plugins/data_visualizer/common/utils/query_utils.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.