Skip to content

Commit

Permalink
Do not fail Evaluate API when the actual and predicted fields' types …
Browse files Browse the repository at this point in the history
…differ (elastic#54255)
  • Loading branch information
przemekwitek committed Mar 27, 2020
1 parent 16692e1 commit 726c487
Show file tree
Hide file tree
Showing 3 changed files with 313 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public final Tuple<List<AggregationBuilder>, List<PipelineAggregationBuilder>> a
if (result.get() == null) { // These are steps 2, 3, 4 etc.
KeyedFilter[] keyedFiltersPredicted =
topActualClassNames.get().stream()
.map(className -> new KeyedFilter(className, QueryBuilders.termQuery(predictedField, className)))
.map(className -> new KeyedFilter(className, QueryBuilders.matchQuery(predictedField, className).lenient(true)))
.toArray(KeyedFilter[]::new);
// Knowing exactly how many buckets does each aggregation use, we can choose the size of the batch so that
// too_many_buckets_exception exception is not thrown.
Expand All @@ -154,7 +154,7 @@ public final Tuple<List<AggregationBuilder>, List<PipelineAggregationBuilder>> a
topActualClassNames.get().stream()
.skip(actualClasses.size())
.limit(actualClassesPerBatch)
.map(className -> new KeyedFilter(className, QueryBuilders.termQuery(actualField, className)))
.map(className -> new KeyedFilter(className, QueryBuilders.matchQuery(actualField, className).lenient(true)))
.toArray(KeyedFilter[]::new);
if (keyedFiltersActual.length > 0) {
return Tuple.tuple(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public final Tuple<List<AggregationBuilder>, List<PipelineAggregationBuilder>> a
if (result.get() == null) { // This is step 2
KeyedFilter[] keyedFiltersPredicted =
topActualClassNames.get().stream()
.map(className -> new KeyedFilter(className, QueryBuilders.termQuery(predictedField, className)))
.map(className -> new KeyedFilter(className, QueryBuilders.matchQuery(predictedField, className).lenient(true)))
.toArray(KeyedFilter[]::new);
Script script = PainlessScripts.buildIsEqualScript(actualField, predictedField);
return Tuple.tuple(
Expand Down
Loading

0 comments on commit 726c487

Please sign in to comment.