Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geo: Switch generated GeoJson type names to camel case (#50285) #50400

Merged
merged 4 commits into from
Dec 20, 2019

Conversation

imotov
Copy link
Contributor

@imotov imotov commented Dec 19, 2019

Switches generated GeoJson type names to camel case
to conform to the standard.

Closes #49568

Switches generated WKT to upper case to conform to
the standard recommendation.

Closes elastic#49568
@imotov imotov added >bug :Analytics/Geo Indexing, search aggregations of geo points and shapes v8.0.0 v7.6.0 labels Dec 19, 2019
@imotov imotov requested a review from talevy December 19, 2019 20:05
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (:Analytics/Geo)

Copy link
Contributor

@talevy talevy left a comment

Choose a reason for hiding this comment

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

I think you meant GeoJson, not WKT?

@@ -382,7 +382,7 @@ public static String getGeoJsonName(Geometry geometry) {
return geometry.visit(new GeometryVisitor<>() {
@Override
public String visit(Circle circle) {
return "circle";
return "CIRCLE";
Copy link
Contributor

Choose a reason for hiding this comment

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

this is for GeoJSON, not WKT. right?

these should all be capitalized using upper-camel-case/pascal-case

Circle, MultiLineString...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed! Got carried away :)

@imotov imotov changed the title Geo: Switch generated WKT to upper case (#50285) Geo: Switch generated GeoJson type names to camel case (#50285) Dec 19, 2019
@imotov
Copy link
Contributor Author

imotov commented Dec 19, 2019

@elasticmachine update branch

@imotov
Copy link
Contributor Author

imotov commented Dec 19, 2019

@elasticmachine update branch

@imotov
Copy link
Contributor Author

imotov commented Dec 20, 2019

@elasticmachine run elasticsearch-ci/2

@imotov imotov merged commit 7f81467 into elastic:master Dec 20, 2019
imotov added a commit that referenced this pull request Dec 20, 2019
Switches generated GeoJson type names to camel case
to conform to the standard.

Closes #49568
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
elastic#50400)

Switches generated GeoJson type names to camel case
to conform to the standard.

Closes elastic#49568
@imotov imotov deleted the issue-49568-uppercase-geojson branch May 1, 2020 22:20
@jennet
Copy link

jennet commented Dec 14, 2021

Hi @imotov
I'm running ElasticSearch 7.16.0 but my geo_shapes are all being returned with lowercase type in their geojson data so I've been trying to find a workaround. This looks from the tags as if it should be fixed in version 7.6+, is that right?
Thanks!

@iverase
Copy link
Contributor

iverase commented Dec 14, 2021

Hi @jennet,

This is right, this change was done on 7.6.0 but it does not mean that you get all geojson not in camelcase. Let me explain.

Lets create an index an insert to points on with camel case and one without:

PUT test

PUT test/_mapping
{
      "properties" : {
        "location" : {
          "type" : "geo_shape"
        }
      }
}

POST /test/_doc
{
  "location": {
    "type" : "point",
    "coordinates" : [0,0]
  }
}

POST /test/_doc
{
  "location": {
    "type" : "Point",
    "coordinates" : [0,0]
  }
}

If you do a search without specifying how to retrieve the values, it returns the _source which is the original document, that is one point lowercase and the second one camel case:

GET test/_search 

{
  "took" : 6,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "test",
        "_id" : "IozZuH0BnP2_brwP3rs9",
        "_score" : 1.0,
        "_source" : {
          "location" : {
            "type" : "point",
            "coordinates" : [
              0,
              0
            ]
          }
        }
      },
      {
        "_index" : "test",
        "_id" : "I4zZuH0BnP2_brwP77sE",
        "_score" : 1.0,
        "_source" : {
          "location" : {
            "type" : "Point",
            "coordinates" : [
              0,
              0
            ]
          }
        }
      }
    ]
  }
}

One the other hand in 7.16 you can use the fields parameter in the request bodyto return data formatted in geojson. In that case both points are camel case:

GET test/_search 
{
  "_source": false, 
  "fields": [
    "location"
  ]
}

{
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "test",
        "_id" : "IozZuH0BnP2_brwP3rs9",
        "_score" : 1.0,
        "fields" : {
          "location" : [
            {
              "coordinates" : [
                0.0,
                0.0
              ],
              "type" : "Point"
            }
          ]
        }
      },
      {
        "_index" : "test",
        "_id" : "I4zZuH0BnP2_brwP77sE",
        "_score" : 1.0,
        "fields" : {
          "location" : [
            {
              "coordinates" : [
                0.0,
                0.0
              ],
              "type" : "Point"
            }
          ]
        }
      }
    ]
  }
}

Hope this helps.

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 v7.6.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WKT and GeoJSON's shape types need proper capitalization
6 participants