Fix handling of points_only with term strategy in geo_shape#31766
Fix handling of points_only with term strategy in geo_shape#31766imotov merged 1 commit intoelastic:masterfrom
Conversation
Fixes 2 issues that together cause errors during index creation with geo_shapes that use the term strategy. The term strategy changes the default for points_only parameter, but this wasn't taken into account during serialization. So, setting the term strategy would add `"points_only": true` to serialization. At the same time if the term strategy would also cause the `points_only` setting to be not marked as a processed element during parsing, which would cause index creation to fail with the error: `Mapping definition for [location] has unsupported parameters: [points_only : true]`. Fixes elastic#31707
|
Pinging @elastic/es-search-aggs |
|
Not sure if it should be backported to 6.3 as well. It seems to be a pretty bad issue essentially making |
| } | ||
| } | ||
| if (pointsOnly != null) { | ||
| if (builder.fieldType().strategyName.equals(SpatialStrategy.TERM.getStrategyName()) && pointsOnly == false) { |
There was a problem hiding this comment.
pointsOnly == false is using reference equality on an object, it works because Boolean.valueOf(boolean) returns singletons, but let's still try to compare the wrapped boolean instead?
There was a problem hiding this comment.
I might be wrong, but I was under impression that this changed recently (around v1.5). According to the spec "If one of the operands is of type Boolean, it is subjected to unboxing conversion." So, I don't think we have a reference equality, but instead auto-unboxing of pointsOnly and boolean comparison with false. I also looked at the bytecode for this line and if I am reading it correctly it looks like unboxing and jump if nonzero.
LINENUMBER 240 L40
ALOAD 4
INVOKEVIRTUAL org/elasticsearch/index/mapper/GeoShapeFieldMapper$Builder.fieldType ()Lorg/elasticsearch/index/mapper/GeoShapeFieldMapper$GeoShapeFieldType;
INVOKESTATIC org/elasticsearch/index/mapper/GeoShapeFieldMapper$GeoShapeFieldType.access$000 (Lorg/elasticsearch/index/mapper/GeoShapeFieldMapper$GeoShapeFieldType;)Ljava/lang/String;
GETSTATIC org/elasticsearch/common/geo/SpatialStrategy.TERM : Lorg/elasticsearch/common/geo/SpatialStrategy;
INVOKEVIRTUAL org/elasticsearch/common/geo/SpatialStrategy.getStrategyName ()Ljava/lang/String;
INVOKEVIRTUAL java/lang/String.equals (Ljava/lang/Object;)Z
IFEQ L41
ALOAD 5
INVOKEVIRTUAL java/lang/Boolean.booleanValue ()Z
IFNE L41
What do you think?
There was a problem hiding this comment.
I didn't know that, thanks for checking!
|
LGTM |
Fixes 2 issues that together cause errors during index creation with geo_shapes that use the term strategy. The term strategy changes the default for points_only parameter, but this wasn't taken into account during serialization. So, setting the term strategy would add `"points_only": true` to serialization. At the same time if the term strategy would also cause the `points_only` setting to be not marked as a processed element during parsing, which would cause index creation to fail with the error: `Mapping definition for [location] has unsupported` `parameters: [points_only : true]`. Fixes #31707
* 6.x: [ML] Fix master node deadlock during ML daily maintenance (#31836) Build: Switch integ-test-zip to OSS-only (#31866) Build: Fix detection of Eclipse Compiler Server (#31838) SQL: Remove restriction for single column grouping (#31818) Docs: Inconsistency between description and example (#31858) Fix and reenable TribeIntegrationTests QA: build improvements related to SQL projects (#31862) muted test [Docs] Add clarification to analysis example (#31826) Check timeZone() argument in AbstractSqlQueryRequest (#31822) Remove obsolete parameters from analyze rest spec (#31795) SQL: Fix incorrect HAVING equality (#31820) Smaller aesthetic fixes to InternalTestCluster (#31831) [Docs] Clarify accepted sort case (#31605) Do not return all indices if a specific alias is requested via get aliases api. (#29538) [Docs] Fix wrong link in Korean analyzer docs (#31815) Fix profiling of ordered terms aggs (#31814) Fix handling of points_only with term strategy in geo_shape (#31766) Docs: Explain _bulk?refresh shard targeting REST high-level client: add get index API (#31703)
* master: [ML] Fix master node deadlock during ML daily maintenance (#31836) Build: Switch integ-test-zip to OSS-only (#31866) SQL: Remove restriction for single column grouping (#31818) Build: Fix detection of Eclipse Compiler Server (#31838) Docs: Inconsistency between description and example (#31858) Re-enable bwc tests now that #29538 has been backported and 6.x intake build succeeded. QA: build improvements related to SQL projects (#31862) [Docs] Add clarification to analysis example (#31826) Check timeZone() argument in AbstractSqlQueryRequest (#31822) SQL: Fix incorrect HAVING equality (#31820) Smaller aesthetic fixes to InternalTestCluster (#31831) [Docs] Clarify accepted sort case (#31605) Temporarily disable bwc test in order to backport #29538 Remove obsolete parameters from analyze rest spec (#31795) [Docs] Fix wrong link in Korean analyzer docs (#31815) Fix profiling of ordered terms aggs (#31814) Properly mute test involving JDK11 closes #31739 Do not return all indices if a specific alias is requested via get aliases api. (#29538) Get snapshot rest client cleanups (#31740) Docs: Explain _bulk?refresh shard targeting Fix handling of points_only with term strategy in geo_shape (#31766)
Fixes 2 issues that together cause errors during index creation
with geo_shapes that use the term strategy. The term strategy changes
the default for points_only parameter, but this wasn't taken into
account during serialization. So, setting the term strategy would add
"points_only": trueto serialization. At the same time if the termstrategy would also cause the
points_onlysetting to be not marked asa processed element during parsing, which would cause index creation to
fail with the error:
Mapping definition for [location] has unsupportedparameters: [points_only : true].Fixes #31707