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

Change GeoHashGrid.Bucket#getKey() to return String #31748

Closed
wants to merge 2 commits into from

Conversation

cbuescher
Copy link
Member

The GeoHashGrid bucket class currently returns a GeoPoint with its getKey()
method. The REST API returns geohash as a String in the key field of the bucket.
This changes the getKey() method to also return a String. Having the ability to
get a GeoPoint from a bucket that represents a geohash cell is misleading
because the cell does not represent a point but an area. Instead, it should be
the clients responsibility to make the decision on how to represent the bucket
key in its application. This also simplifies implementing the high level rest
client aspects of #30320, as the client will not need to know about the
GeoHashType being used and will only care that there is some string key for the
buckets.

Relates to #30320

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@@ -77,7 +77,7 @@ private static long longEncode(final String hash, int length) {
long b;
long l = 0L;
for(char c : hash.toCharArray()) {
b = (long)(BASE_32_STRING.indexOf(c));
b = BASE_32_STRING.indexOf(c);
Copy link
Member Author

Choose a reason for hiding this comment

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

My IDE made me do it ;-) Can revert if it is confusing in this PR.

The GeoHashGrid bucket class currently returns a GeoPoint with its getKey()
method. The REST API returns geohash as a String in the key field of the bucket.
This changes the getKey() method to also return a String. Having the ability to
get a GeoPoint from a bucket that represents a geohash cell is misleading
because the cell does not represent a point but an area. Instead, it should be
the clients responsibility to make the decision on how to represent the bucket
key in its application. This also simplifies implementing the high level rest
client aspects of elastic#30320, as the client will not need to know about the
GeoHashType being used and will only care that there is some string key for the
buckets.

Relates to elastic#30320
@cbuescher cbuescher force-pushed the change-geoHashGrid-getKey branch from 504ef9a to 0349b62 Compare July 2, 2018 19:10
@cbuescher
Copy link
Member Author

@colings86 could you take a look if this is enough to close #31748? I was looking at a way to deprecate sth. here but since the method signature is "Object getKey()" in MultiBucketsAggregation.Bucket there is not much we can change. Users will need to cast the result anyway if they want to use the bucket keys for anything.

@cbuescher
Copy link
Member Author

Closing, as there is a separate plan now: #30320 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants