[TEST] Fix geo_point backcompat tests
This commit fixes the following geo_point bwc tests: * GeoDistanceIT to test deprecated GeoDistanceRangeQuery on legacy indexes only. * ExternalFieldMapperTests to correctly handle LatLonPoint type * GeoPointFieldMapperTests to correctly test stored geo_point fields
This commit is contained in:
parent
482f00f93c
commit
87b06c75b0
|
@ -86,8 +86,10 @@ public class ExternalFieldMapperTests extends ESSingleNodeTestCase {
|
|||
assertThat(doc.rootDoc().getField("field.point"), notNullValue());
|
||||
if (version.before(Version.V_2_2_0)) {
|
||||
assertThat(doc.rootDoc().getField("field.point").stringValue(), is("42.0,51.0"));
|
||||
} else if (version.after(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
|
||||
assertThat(Long.parseLong(doc.rootDoc().getField("field.point").stringValue()), is(GeoPointField.encodeLatLon(42.0, 51.0)));
|
||||
} else if (version.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
|
||||
GeoPoint point = new GeoPoint().resetFromIndexableField(doc.rootDoc().getField("field.point"));
|
||||
assertThat(point.lat(), closeTo(42.0, 1e-5));
|
||||
assertThat(point.lon(), closeTo(51.0, 1e-5));
|
||||
}
|
||||
|
||||
assertThat(doc.rootDoc().getField("field.shape"), notNullValue());
|
||||
|
|
|
@ -452,7 +452,11 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
|||
|
||||
// doc values are enabled by default, but in this test we disable them; we should only have 2 points
|
||||
assertThat(doc.rootDoc().getFields("point"), notNullValue());
|
||||
assertThat(doc.rootDoc().getFields("point").length, equalTo(2));
|
||||
if (version.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
|
||||
assertThat(doc.rootDoc().getFields("point").length, equalTo(4));
|
||||
} else {
|
||||
assertThat(doc.rootDoc().getFields("point").length, equalTo(2));
|
||||
}
|
||||
if (version.before(Version.V_5_0_0_alpha2)) {
|
||||
assertThat(doc.rootDoc().getFields("point.lat").length, equalTo(2));
|
||||
assertThat(doc.rootDoc().getFields("point.lon").length, equalTo(2));
|
||||
|
|
|
@ -67,8 +67,8 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|||
return Arrays.asList(InternalSettingsPlugin.class);
|
||||
}
|
||||
|
||||
public void testSimpleDistance() throws Exception {
|
||||
Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
|
||||
public void testLegacyGeoDistanceRangeQuery() throws Exception {
|
||||
Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.V_2_4_0);
|
||||
Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
|
||||
.startObject("location").field("type", "geo_point");
|
||||
|
|
Loading…
Reference in New Issue