Skip to content

Commit

Permalink
[ML] Changing job wizard query to use match_all (elastic#32008)
Browse files Browse the repository at this point in the history
* [ML] Using job wizard query to use match_all

* adding query back in for data visualizer

* fixing typo
  • Loading branch information
jgowdyelastic committed Feb 28, 2019
1 parent 58b37bd commit cce62d6
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ module.directive('mlBucketSpanEstimator', function (i18n) {
end: $scope.formConfig.end
},
fields: [],
filters: $scope.formConfig.filters,
index: $scope.formConfig.indexPattern.title,
query: $scope.formConfig.combinedQuery,
splitField: $scope.formConfig.splitField && $scope.formConfig.splitField.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ module
const {
indexPattern,
savedSearch,
query,
filters,
combinedQuery } = createSearchItems();

timeBasedIndexCheck(indexPattern, true);
Expand Down Expand Up @@ -231,8 +229,6 @@ module
influencerFields: [],
firstSplitFieldName: undefined,
indexPattern,
query,
filters,
combinedQuery,
usesSavedSearch: (savedSearch.id !== undefined),
jobId: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ module
const {
indexPattern,
savedSearch,
query,
filters,
combinedQuery } = createSearchItems();

timeBasedIndexCheck(indexPattern, true);
Expand Down Expand Up @@ -234,8 +232,6 @@ module
influencerFields: [],
firstSplitFieldName: undefined,
indexPattern: indexPattern,
query,
filters,
combinedQuery,
usesSavedSearch: (savedSearch.id !== undefined),
jobId: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ module
const {
indexPattern,
savedSearch,
query,
combinedQuery } = createSearchItems();

const pageTitle = (savedSearch.id !== undefined) ?
Expand Down Expand Up @@ -143,8 +142,6 @@ module
kibanaObjects: {},
start: 0,
end: 0,
query,
filters: [],
useFullIndexData: true,
startDatafeedAfterSave: true,
useDedicatedIndex: false,
Expand All @@ -155,7 +152,6 @@ module
$scope.resetJob = function () {
$scope.overallState = SAVE_STATE.NOT_SAVED;
$scope.formConfig.jobs = [];
$scope.formConfig.filters = [];
$scope.formConfig.kibanaObjects = {};

loadJobConfigs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ module
const {
indexPattern,
savedSearch,
query,
filters,
combinedQuery } = createSearchItems();

timeBasedIndexCheck(indexPattern, true);
Expand Down Expand Up @@ -241,8 +239,6 @@ module
timeField: indexPattern.timeFieldName,
indexPattern: undefined,
usesSavedSearch: (savedSearch.id !== undefined),
query,
filters,
combinedQuery,
jobId: '',
description: '',
Expand Down
21 changes: 9 additions & 12 deletions x-pack/plugins/ml/public/jobs/new_job/utils/new_job_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,23 @@ export function SearchItemsProvider(Private, $route, config) {
function createSearchItems() {
let indexPattern = $route.current.locals.indexPattern;

// query is only used by the data visualizer as it needs
// a lucene query_string.
// Using a blank query will cause match_all:{} to be used
// when passed through luceneStringToDsl
let query = {
query: '*',
query: '',
language: 'lucene'
};

let combinedQuery = {
bool: {
must: [{
query_string: {
analyze_wildcard: true,
query: '*'
}
match_all: {}
}]
}
};

let filters = [];

const savedSearch = $route.current.locals.savedSearch;
if (indexPattern.id === undefined && savedSearch.id !== undefined) {
const searchSource = savedSearch.searchSource;
Expand All @@ -46,19 +45,17 @@ export function SearchItemsProvider(Private, $route, config) {
query = searchSource.getField('query');
const fs = searchSource.getField('filter');

if (fs.length) {
filters = fs;
}
const filters = (fs.length) ? fs : [];

const esQueryConfigs = getEsQueryConfig(config);
combinedQuery = buildEsQuery(indexPattern, [query], filters, esQueryConfigs);
}

return {
indexPattern,
savedSearch,
filters,
query,
combinedQuery
combinedQuery,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ const formConfig = {
aggTypes: ['count'],
duration: {},
fields: [null],
filters: [],
index: '',
query: {
bool: {
must: [{ query_string: { analyze_wildcard: true, query: '*' } }],
must: [{ match_all: {} }],
must_not: []
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,6 @@ export function estimateBucketSpanFactory(callWithRequest, server) {
throw new Error('Invalid formConfig: Missing fields.');
}

if (typeof formConfig.filters === 'undefined') {
throw new Error('Invalid formConfig: Missing filters.');
}

if (typeof formConfig.query === 'undefined') {
throw new Error('Invalid formConfig: Missing query.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export async function validateBucketSpan(callWithRequest, job, duration, server)
aggTypes: [],
duration,
fields: [],
filters: [],
index: job.datafeed_config.indices.join(','),
query: wrapQuery(job.datafeed_config.query),
splitField: undefined,
Expand Down

0 comments on commit cce62d6

Please sign in to comment.