Skip to content

Commit

Permalink
[ML] fix context chart
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Mar 30, 2020
1 parent 19b2b5c commit 49f2225
Showing 2 changed files with 8 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1259,39 +1259,13 @@ export function getRecordMaxScoreByTime(jobId, criteriaFields, earliestMs, lates
},
{ term: { job_id: jobId } },
];
const shouldCriteria = [];

_.each(criteriaFields, criteria => {
if (criteria.fieldValue.length !== 0) {
mustCriteria.push({
term: {
[criteria.fieldName]: criteria.fieldValue,
},
});
} else {
// Add special handling for blank entity field values, checking for either
// an empty string or the field not existing.
const emptyFieldCondition = {
bool: {
must: [
{
term: {},
},
],
},
};
emptyFieldCondition.bool.must[0].term[criteria.fieldName] = '';
shouldCriteria.push(emptyFieldCondition);
shouldCriteria.push({
bool: {
must_not: [
{
exists: { field: criteria.fieldName },
},
],
},
});
}
mustCriteria.push({
term: {
[criteria.fieldName]: criteria.fieldValue,
},
});
});

ml.esSearch({
Original file line number Diff line number Diff line change
@@ -63,7 +63,9 @@ export class EntityControl extends Component<EntityControlProps, EntityControlSt
selectedOptions[0].value !== fieldValue &&
fieldValue !== null)
) {
selectedOptionsUpdate = [{ label: EMPTY_FIELD_VALUE_LABEL, value: fieldValue }];
selectedOptionsUpdate = [
{ label: fieldValue === '' ? EMPTY_FIELD_VALUE_LABEL : fieldValue, value: fieldValue },
];
} else if (Array.isArray(selectedOptions) && fieldValue === null) {
selectedOptionsUpdate = undefined;
}

0 comments on commit 49f2225

Please sign in to comment.