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
  • Loading branch information
przemekwitek committed Mar 26, 2020
1 parent 18843a0 commit a853e82
Show file tree
Hide file tree
Showing 3 changed files with 270 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,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 @@ -153,7 +153,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 @@ -107,7 +107,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 a853e82

Please sign in to comment.