Skip to content

Conversation

@imotov
Copy link
Contributor

@imotov imotov commented Jul 3, 2018

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

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
@imotov imotov added >bug :Analytics/Geo Indexing, search aggregations of geo points and shapes :Search Foundations/Mapping Index mappings, including merging and defining field types v7.0.0 v6.4.0 labels Jul 3, 2018
@imotov imotov requested a review from jpountz July 3, 2018 14:55
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@imotov
Copy link
Contributor Author

imotov commented Jul 3, 2018

Not sure if it should be backported to 6.3 as well. It seems to be a pretty bad issue essentially making strategy: term unusable.

}
}
if (pointsOnly != null) {
if (builder.fieldType().strategyName.equals(SpatialStrategy.TERM.getStrategyName()) && pointsOnly == false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know that, thanks for checking!

@jpountz
Copy link
Contributor

jpountz commented Jul 5, 2018

LGTM

@imotov imotov merged commit 94d3ddd into elastic:master Jul 5, 2018
imotov added a commit that referenced this pull request Jul 5, 2018
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
dnhatn added a commit that referenced this pull request Jul 7, 2018
* 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)
dnhatn added a commit that referenced this pull request Jul 7, 2018
* 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)
@jpountz jpountz removed the :Search Foundations/Mapping Index mappings, including merging and defining field types label Jan 29, 2019
@imotov imotov deleted the issue-31707-points-only branch May 1, 2020 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug v6.4.0 v7.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants