diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation_saved_search.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation_saved_search.ts index 67550ae17a4b0..b47a80c3041e2 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation_saved_search.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation_saved_search.ts @@ -19,6 +19,13 @@ export default function ({ getService }: FtrProviderContext) { await ml.testResources.createIndexPatternIfNeeded('ft_farequote_small', '@timestamp'); await ml.testResources.createSavedSearchFarequoteLuceneIfNeeded('ft_farequote_small'); await ml.testResources.createSavedSearchFarequoteKueryIfNeeded('ft_farequote_small'); + // Need to use the saved searches with filters that match multiple airlines + await ml.testResources.createSavedSearchFarequoteFilterTwoAndLuceneIfNeeded( + 'ft_farequote_small' + ); + await ml.testResources.createSavedSearchFarequoteFilterTwoAndKueryIfNeeded( + 'ft_farequote_small' + ); await ml.testResources.setKibanaTimeZoneToUTC(); await ml.securityUI.loginAsMlPowerUser(); @@ -134,6 +141,110 @@ export default function ({ getService }: FtrProviderContext) { } as AnalyticsTableRowDetails, }, }, + { + suiteTitle: 'with filter and lucene query', + jobType: 'classification', + jobId: `fq_saved_search_4_${dateNow}`, + jobDescription: 'Classification job based on a saved search with filter and lucene query', + source: 'ft_farequote_filter_two_and_lucene', + get destinationIndex(): string { + return `user-${this.jobId}`; + }, + runtimeFields: { + uppercase_airline: { + type: 'keyword', + script: 'emit(params._source.airline.toUpperCase())', + }, + }, + dependentVariable: 'airline', + trainingPercent: 20, + modelMemory: '20mb', + createIndexPattern: true, + expected: { + source: 'ft_farequote_small', + rocCurveColorState: [ + // tick/grid/axis + { color: '#DDDDDD', percentage: 38 }, + // line + { color: '#98A2B3', percentage: 7 }, + ], + runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'], + row: { + memoryStatus: 'ok', + type: 'classification', + status: 'stopped', + progress: '100', + }, + rowDetails: { + jobDetails: [ + { + section: 'state', + expectedEntries: { + id: `fq_saved_search_4_${dateNow}`, + state: 'stopped', + data_counts: + '{"training_docs_count":135,"test_docs_count":544,"skipped_docs_count":0}', + description: + 'Classification job based on a saved search with filter and lucene query', + }, + }, + { section: 'progress', expectedEntries: { Phase: '8/8' } }, + ], + } as AnalyticsTableRowDetails, + }, + }, + { + suiteTitle: 'with filter and kuery query', + jobType: 'classification', + jobId: `fq_saved_search_5_${dateNow}`, + jobDescription: 'Classification job based on a saved search with filter and kuery query', + source: 'ft_farequote_filter_two_and_kuery', + get destinationIndex(): string { + return `user-${this.jobId}`; + }, + runtimeFields: { + uppercase_airline: { + type: 'keyword', + script: 'emit(params._source.airline.toUpperCase())', + }, + }, + dependentVariable: 'airline', + trainingPercent: 20, + modelMemory: '20mb', + createIndexPattern: true, + expected: { + source: 'ft_farequote_small', + rocCurveColorState: [ + // tick/grid/axis + { color: '#DDDDDD', percentage: 38 }, + // line + { color: '#98A2B3', percentage: 7 }, + ], + runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'], + row: { + memoryStatus: 'ok', + type: 'classification', + status: 'stopped', + progress: '100', + }, + rowDetails: { + jobDetails: [ + { + section: 'state', + expectedEntries: { + id: `fq_saved_search_5_${dateNow}`, + state: 'stopped', + data_counts: + '{"training_docs_count":109,"test_docs_count":436,"skipped_docs_count":0}', + description: + 'Classification job based on a saved search with filter and kuery query', + }, + }, + { section: 'progress', expectedEntries: { Phase: '8/8' } }, + ], + } as AnalyticsTableRowDetails, + }, + }, ]; for (const testData of testDataList) { diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/outlier_detection_creation_saved_search.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/outlier_detection_creation_saved_search.ts index 1dc431c74a97d..cd6690202e203 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/outlier_detection_creation_saved_search.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/outlier_detection_creation_saved_search.ts @@ -19,6 +19,10 @@ export default function ({ getService }: FtrProviderContext) { await ml.testResources.createIndexPatternIfNeeded('ft_farequote_small', '@timestamp'); await ml.testResources.createSavedSearchFarequoteLuceneIfNeeded('ft_farequote_small'); await ml.testResources.createSavedSearchFarequoteKueryIfNeeded('ft_farequote_small'); + await ml.testResources.createSavedSearchFarequoteFilterAndLuceneIfNeeded( + 'ft_farequote_small' + ); + await ml.testResources.createSavedSearchFarequoteFilterAndKueryIfNeeded('ft_farequote_small'); await ml.testResources.setKibanaTimeZoneToUTC(); await ml.securityUI.loginAsMlPowerUser(); @@ -56,22 +60,6 @@ export default function ({ getService }: FtrProviderContext) { { chartAvailable: true, id: 'responsetime', legend: '4.91 - 171.08' }, { chartAvailable: true, id: 'airline', legend: '5 categories' }, ], - scatterplotMatrixColorsWizard: [ - // markers - { color: '#52B398', percentage: 15 }, - // grey boilerplate - { color: '#6A717D', percentage: 13 }, - ], - scatterplotMatrixColorStatsResults: [ - // red markers - { color: '#D98071', percentage: 1 }, - // tick/grid/axis, grey markers - { color: '#6A717D', percentage: 12 }, - { color: '#D3DAE6', percentage: 8 }, - { color: '#98A1B3', percentage: 12 }, - // anti-aliasing - { color: '#F5F7FA', percentage: 30 }, - ], runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'], row: { memoryStatus: 'ok', @@ -120,22 +108,6 @@ export default function ({ getService }: FtrProviderContext) { { chartAvailable: true, id: 'responsetime', legend: '9.91 - 171.08' }, { chartAvailable: true, id: 'airline', legend: '5 categories' }, ], - scatterplotMatrixColorsWizard: [ - // markers - { color: '#52B398', percentage: 15 }, - // grey boilerplate - { color: '#6A717D', percentage: 13 }, - ], - scatterplotMatrixColorStatsResults: [ - // red markers - { color: '#D98071', percentage: 1 }, - // tick/grid/axis, grey markers - { color: '#6A717D', percentage: 12 }, - { color: '#D3DAE6', percentage: 8 }, - { color: '#98A1B3', percentage: 12 }, - // anti-aliasing - { color: '#F5F7FA', percentage: 30 }, - ], runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'], row: { memoryStatus: 'ok', @@ -160,6 +132,105 @@ export default function ({ getService }: FtrProviderContext) { } as AnalyticsTableRowDetails, }, }, + { + suiteTitle: 'with filter and kuery query', + jobType: 'outlier_detection', + jobId: `fq_saved_search_4_${dateNow}`, + jobDescription: 'Outlier detection job based on a saved search with filter and kuery query', + source: 'ft_farequote_filter_and_kuery', + get destinationIndex(): string { + return `user-${this.jobId}`; + }, + runtimeFields: { + uppercase_airline: { + type: 'keyword', + script: 'emit(params._source.airline.toUpperCase())', + }, + }, + modelMemory: '65mb', + createIndexPattern: true, + expected: { + source: 'ft_farequote_small', + histogramCharts: [ + { chartAvailable: true, id: 'uppercase_airline', legend: '1 category' }, + { chartAvailable: true, id: 'responsetime', legend: '57.2 - 96.77' }, + { chartAvailable: true, id: 'airline', legend: '1 category' }, + ], + runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'], + row: { + memoryStatus: 'ok', + type: 'outlier_detection', + status: 'stopped', + progress: '100', + }, + rowDetails: { + jobDetails: [ + { + section: 'state', + expectedEntries: { + id: `fq_saved_search_4_${dateNow}`, + state: 'stopped', + data_counts: + '{"training_docs_count":290,"test_docs_count":0,"skipped_docs_count":0}', + description: + 'Outlier detection job based on a saved search with filter and kuery query', + }, + }, + { section: 'progress', expectedEntries: { Phase: '4/4' } }, + ], + } as AnalyticsTableRowDetails, + }, + }, + { + suiteTitle: 'with filter and lucene query', + jobType: 'outlier_detection', + jobId: `fq_saved_search_5_${dateNow}`, + jobDescription: + 'Outlier detection job based on a saved search with filter and lucene query', + source: 'ft_farequote_filter_and_lucene', + get destinationIndex(): string { + return `user-${this.jobId}`; + }, + runtimeFields: { + uppercase_airline: { + type: 'keyword', + script: 'emit(params._source.airline.toUpperCase())', + }, + }, + modelMemory: '65mb', + createIndexPattern: true, + expected: { + source: 'ft_farequote_small', + histogramCharts: [ + { chartAvailable: true, id: 'uppercase_airline', legend: '1 category' }, + { chartAvailable: true, id: 'responsetime', legend: '57.2 - 96.77' }, + { chartAvailable: true, id: 'airline', legend: '1 category' }, + ], + runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'], + row: { + memoryStatus: 'ok', + type: 'outlier_detection', + status: 'stopped', + progress: '100', + }, + rowDetails: { + jobDetails: [ + { + section: 'state', + expectedEntries: { + id: `fq_saved_search_5_${dateNow}`, + state: 'stopped', + data_counts: + '{"training_docs_count":290,"test_docs_count":0,"skipped_docs_count":0}', + description: + 'Outlier detection job based on a saved search with filter and lucene query', + }, + }, + { section: 'progress', expectedEntries: { Phase: '4/4' } }, + ], + } as AnalyticsTableRowDetails, + }, + }, ]; for (const testData of testDataList) { diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation_saved_search.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation_saved_search.ts index e22c4908486d1..171ab6ee8c51e 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation_saved_search.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation_saved_search.ts @@ -19,6 +19,10 @@ export default function ({ getService }: FtrProviderContext) { await ml.testResources.createIndexPatternIfNeeded('ft_farequote_small', '@timestamp'); await ml.testResources.createSavedSearchFarequoteLuceneIfNeeded('ft_farequote_small'); await ml.testResources.createSavedSearchFarequoteKueryIfNeeded('ft_farequote_small'); + await ml.testResources.createSavedSearchFarequoteFilterAndLuceneIfNeeded( + 'ft_farequote_small' + ); + await ml.testResources.createSavedSearchFarequoteFilterAndKueryIfNeeded('ft_farequote_small'); await ml.testResources.setKibanaTimeZoneToUTC(); await ml.securityUI.loginAsMlPowerUser(); @@ -122,6 +126,97 @@ export default function ({ getService }: FtrProviderContext) { } as AnalyticsTableRowDetails, }, }, + { + suiteTitle: 'with filter and kuery query', + jobType: 'regression', + jobId: `fq_saved_search_4_${dateNow}`, + jobDescription: 'Regression job based on a saved search with filter and kuery query', + source: 'ft_farequote_filter_and_kuery', + get destinationIndex(): string { + return `user-${this.jobId}`; + }, + runtimeFields: { + uppercase_airline: { + type: 'keyword', + script: 'emit(params._source.airline.toUpperCase())', + }, + }, + dependentVariable: 'responsetime', + trainingPercent: 20, + modelMemory: '20mb', + createIndexPattern: true, + expected: { + source: 'ft_farequote_small', + runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'], + row: { + memoryStatus: 'ok', + type: 'regression', + status: 'stopped', + progress: '100', + }, + rowDetails: { + jobDetails: [ + { + section: 'state', + expectedEntries: { + id: `fq_saved_search_4_${dateNow}`, + state: 'stopped', + data_counts: + '{"training_docs_count":58,"test_docs_count":232,"skipped_docs_count":0}', + description: 'Regression job based on a saved search with filter and kuery query', + }, + }, + { section: 'progress', expectedEntries: { Phase: '8/8' } }, + ], + } as AnalyticsTableRowDetails, + }, + }, + { + suiteTitle: 'with filter and lucene query', + jobType: 'regression', + jobId: `fq_saved_search_5_${dateNow}`, + jobDescription: 'Regression job based on a saved search with filter and lucene query', + source: 'ft_farequote_filter_and_lucene', + get destinationIndex(): string { + return `user-${this.jobId}`; + }, + runtimeFields: { + uppercase_airline: { + type: 'keyword', + script: 'emit(params._source.airline.toUpperCase())', + }, + }, + dependentVariable: 'responsetime', + trainingPercent: 20, + modelMemory: '20mb', + createIndexPattern: true, + expected: { + source: 'ft_farequote_small', + runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'], + row: { + memoryStatus: 'ok', + type: 'regression', + status: 'stopped', + progress: '100', + }, + rowDetails: { + jobDetails: [ + { + section: 'state', + expectedEntries: { + id: `fq_saved_search_5_${dateNow}`, + state: 'stopped', + data_counts: + '{"training_docs_count":58,"test_docs_count":232,"skipped_docs_count":0}', + description: + 'Regression job based on a saved search with filter and lucene query', + }, + }, + { section: 'progress', expectedEntries: { Phase: '8/8' } }, + ], + } as AnalyticsTableRowDetails, + }, + }, ]; for (const testData of testDataList) { diff --git a/x-pack/test/functional/services/ml/test_resources.ts b/x-pack/test/functional/services/ml/test_resources.ts index 27faf74073184..4fccde6712e62 100644 --- a/x-pack/test/functional/services/ml/test_resources.ts +++ b/x-pack/test/functional/services/ml/test_resources.ts @@ -275,6 +275,24 @@ export function MachineLearningTestResourcesProvider( ); }, + async createSavedSearchFarequoteFilterTwoAndLuceneIfNeeded( + indexPatternTitle: string = 'ft_farequote' + ) { + await this.createSavedSearchIfNeeded( + savedSearches.farequoteFilterTwoAndLucene, + indexPatternTitle + ); + }, + + async createSavedSearchFarequoteFilterTwoAndKueryIfNeeded( + indexPatternTitle: string = 'ft_farequote' + ) { + await this.createSavedSearchIfNeeded( + savedSearches.farequoteFilterTwoAndKuery, + indexPatternTitle + ); + }, + async deleteSavedObjectById(id: string, objectType: SavedObjectType, force: boolean = false) { log.debug(`Deleting ${objectType} with id '${id}'...`); diff --git a/x-pack/test/functional/services/ml/test_resources_data.ts b/x-pack/test/functional/services/ml/test_resources_data.ts index aeacc51cecbc9..ac5c2241de81f 100644 --- a/x-pack/test/functional/services/ml/test_resources_data.ts +++ b/x-pack/test/functional/services/ml/test_resources_data.ts @@ -242,6 +242,132 @@ export const savedSearches = { ], }, }, + farequoteFilterTwoAndLucene: { + requestBody: { + attributes: { + title: 'ft_farequote_filter_two_and_lucene', + description: '', + hits: 0, + columns: ['_source'], + sort: ['@timestamp', 'desc'], + version: 1, + kibanaSavedObjectMeta: { + searchSourceJSON: { + highlightAll: true, + version: true, + query: { + query: 'responsetime:>50', + language: 'lucene', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrases', + key: 'airline', + params: ['ASA', 'AAL'], + }, + query: { + bool: { + should: [ + { + match_phrase: { + airline: 'ASA', + }, + }, + { + match_phrase: { + airline: 'AAL', + }, + }, + ], + minimum_should_match: 1, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }, + }, + }, + references: [ + { + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + id: 'INDEX_PATTERN_ID_PLACEHOLDER', + }, + ], + }, + }, + farequoteFilterTwoAndKuery: { + requestBody: { + attributes: { + title: 'ft_farequote_filter_two_and_kuery', + description: '', + hits: 0, + columns: ['_source'], + sort: ['@timestamp', 'desc'], + version: 1, + kibanaSavedObjectMeta: { + searchSourceJSON: { + highlightAll: true, + version: true, + query: { + query: 'responsetime > 49', + language: 'kuery', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrases', + key: 'airline', + params: ['ASA', 'FFT'], + }, + query: { + bool: { + should: [ + { + match_phrase: { + airline: 'ASA', + }, + }, + { + match_phrase: { + airline: 'FFT', + }, + }, + ], + minimum_should_match: 1, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }, + }, + }, + references: [ + { + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + id: 'INDEX_PATTERN_ID_PLACEHOLDER', + }, + ], + }, + }, }; export const dashboards = {