Skip to content

Commit d95c6a0

Browse files
committed
fixed hash_type and a possible nullref
1 parent 54ef54e commit d95c6a0

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

qa/rolling-upgrade/src/test/resources/rest-api-spec/test/upgraded_cluster/10_basic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
aggregations:
128128
mygrid:
129129
geohash_grid:
130-
type: geohash
130+
hash_type: geohash
131131
field : location
132132
precision : 1
133133
- match: { hits.total: 6 }

server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregationBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public static GeoGridAggregationBuilder parse(String aggregationName, XContentPa
111111
public GeoGridAggregationBuilder(String name, GeoHashType type) {
112112
super(name, ValuesSourceType.GEOPOINT, ValueType.GEOPOINT);
113113
this.type = type == null ? GeoHashType.DEFAULT : type;
114-
this.precision = type.getHandler().getDefaultPrecision();
114+
this.precision = this.type.getHandler().getDefaultPrecision();
115115
}
116116

117117
protected GeoGridAggregationBuilder(GeoGridAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metaData) {

server/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static int maxPrecision(GeoHashType type) {
5959
@Override
6060
protected GeoGridAggregationBuilder createTestAggregatorBuilder() {
6161
String name = randomAlphaOfLengthBetween(3, 20);
62-
String type = randomBoolean() ? randomType().toString() : null;
62+
GeoHashType type = randomBoolean() ? randomType() : null;
6363
GeoGridAggregationBuilder factory = new GeoGridAggregationBuilder(name, type);
6464
if (randomBoolean()) {
6565
factory.precision(randomPrecision(factory.type()));

server/src/test/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridParserTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void testParseValidFromInts() throws Exception {
3535
GeoHashType type = GeoHashGridTests.randomType();
3636
int precision = GeoHashGridTests.randomPrecision(type);
3737
XContentParser stParser = createParser(JsonXContent.jsonXContent,
38-
"{\"field\":\"my_loc\", \"type\":\"" + type + "\", \"precision\":" + precision +
38+
"{\"field\":\"my_loc\", \"hash_type\":\"" + type + "\", \"precision\":" + precision +
3939
", \"size\": 500, \"shard_size\": 550}");
4040
XContentParser.Token token = stParser.nextToken();
4141
assertSame(XContentParser.Token.START_OBJECT, token);
@@ -47,7 +47,7 @@ public void testParseValidFromStrings() throws Exception {
4747
GeoHashType type = GeoHashGridTests.randomType();
4848
int precision = GeoHashGridTests.randomPrecision(type);
4949
XContentParser stParser = createParser(JsonXContent.jsonXContent,
50-
"{\"field\":\"my_loc\", \"type\":\"" + type + "\", \"precision\":\"" + precision +
50+
"{\"field\":\"my_loc\", \"hash_type\":\"" + type + "\", \"precision\":\"" + precision +
5151
"\", \"size\": \"500\", \"shard_size\": \"550\"}");
5252
XContentParser.Token token = stParser.nextToken();
5353
assertSame(XContentParser.Token.START_OBJECT, token);
@@ -112,7 +112,7 @@ public void testParseDistanceUnitPrecisionTooSmall() throws Exception {
112112
public void testParseErrorOnBooleanPrecision() throws Exception {
113113
GeoHashType type = GeoHashGridTests.randomType();
114114
XContentParser stParser = createParser(JsonXContent.jsonXContent,
115-
"{\"field\":\"my_loc\", \"type\":\"" + type + "\", \"precision\":false}");
115+
"{\"field\":\"my_loc\", \"hash_type\":\"" + type + "\", \"precision\":false}");
116116
XContentParser.Token token = stParser.nextToken();
117117
assertSame(XContentParser.Token.START_OBJECT, token);
118118
XContentParseException ex = expectThrows(XContentParseException.class,
@@ -129,7 +129,7 @@ public void testParseErrorOnPrecisionOutOfRange() throws Exception {
129129
final GeoHashType type = GeoHashGridTests.randomType();
130130
final int precision = GeoHashGridTests.maxPrecision(type) + 1;
131131
XContentParser stParser = createParser(JsonXContent.jsonXContent,
132-
"{\"field\":\"my_loc\", \"type\":\"" + type + "\", \"precision\":\""+ precision +"\"}");
132+
"{\"field\":\"my_loc\", \"hash_type\":\"" + type + "\", \"precision\":\""+ precision +"\"}");
133133
XContentParser.Token token = stParser.nextToken();
134134
assertSame(XContentParser.Token.START_OBJECT, token);
135135
try {

0 commit comments

Comments
 (0)