Skip to content

Commit

Permalink
[ML] Fix new job with must_not saved search
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Jul 15, 2020
1 parent a1e511a commit 872364d
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ export function createSearchItems(
}
const filterQuery = esQuery.buildQueryFromFilters(filters, indexPattern);

if (combinedQuery.bool.filter === undefined) {
combinedQuery.bool.filter = [];
if (Array.isArray(combinedQuery.bool.filter) === false) {
combinedQuery.bool.filter =
combinedQuery.bool.filter === undefined ? [] : [combinedQuery.bool.filter];
}
if (combinedQuery.bool.must_not === undefined) {
combinedQuery.bool.must_not = [];

if (Array.isArray(combinedQuery.bool.must_not) === false) {
combinedQuery.bool.must_not =
combinedQuery.bool.must_not === undefined ? [] : [combinedQuery.bool.must_not];
}

combinedQuery.bool.filter = [...combinedQuery.bool.filter, ...filterQuery.filter];
combinedQuery.bool.must_not = [...combinedQuery.bool.must_not, ...filterQuery.must_not];
} else {
Expand Down

0 comments on commit 872364d

Please sign in to comment.