浏览代码

Update docs for LatLonPoint cut over

This commit removes documentation for:

* geohash cell query
* lat_lon parameter
* geohash parameter
* geohash_precision parameter
* geohash_prefix parameter

It also updates failing tests that reference these parameters for backcompat.
Nicholas Knize 9 年之前
父节点
当前提交
1a60e1c3d2
共有 30 个文件被更改,包括 111 次插入494 次删除
  1. 5 2
      core/src/main/java/org/elasticsearch/common/geo/GeoPoint.java
  2. 1 3
      core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointDVIndexFieldData.java
  3. 0 3
      core/src/main/java/org/elasticsearch/index/fielddata/plain/LatLonPointDVAtomicFieldData.java
  4. 3 3
      core/src/main/java/org/elasticsearch/index/mapper/BaseGeoPointFieldMapper.java
  5. 10 2
      core/src/main/java/org/elasticsearch/index/mapper/LatLonPointFieldMapper.java
  6. 2 1
      core/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java
  7. 2 1
      core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryBuilder.java
  8. 2 1
      core/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryBuilder.java
  9. 8 1
      core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java
  10. 9 3
      core/src/test/java/org/elasticsearch/index/mapper/ExternalFieldMapperTests.java
  11. 1 1
      core/src/test/java/org/elasticsearch/index/mapper/ExternalMapper.java
  12. 35 30
      core/src/test/java/org/elasticsearch/index/mapper/GeoPointFieldMapperTests.java
  13. 3 2
      core/src/test/java/org/elasticsearch/index/query/GeoDistanceQueryBuilderTests.java
  14. 4 3
      core/src/test/java/org/elasticsearch/index/query/GeoDistanceRangeQueryTests.java
  15. 12 3
      core/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java
  16. 3 2
      core/src/test/java/org/elasticsearch/index/query/GeohashCellQueryBuilderTests.java
  17. 3 1
      core/src/test/java/org/elasticsearch/index/query/NestedQueryBuilderTests.java
  18. 5 1
      core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java
  19. 0 8
      docs/java-api/query-dsl/geo-queries.asciidoc
  20. 0 17
      docs/java-api/query-dsl/geohash-cell-query.asciidoc
  21. 0 4
      docs/reference/api-conventions.asciidoc
  22. 0 72
      docs/reference/mapping/params/geohash-precision.asciidoc
  23. 0 74
      docs/reference/mapping/params/geohash-prefix.asciidoc
  24. 0 78
      docs/reference/mapping/params/geohash.asciidoc
  25. 0 80
      docs/reference/mapping/params/lat-lon.asciidoc
  26. 1 2
      docs/reference/mapping/types/geo-point.asciidoc
  27. 0 7
      docs/reference/query-dsl/geo-queries.asciidoc
  28. 0 81
      docs/reference/query-dsl/geohash-cell-query.asciidoc
  29. 0 7
      docs/reference/redirects.asciidoc
  30. 2 1
      test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java

+ 5 - 2
core/src/main/java/org/elasticsearch/common/geo/GeoPoint.java

@@ -25,7 +25,9 @@ import org.apache.lucene.geo.GeoEncodingUtils;
 import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.spatial.geopoint.document.GeoPointField;
 import org.apache.lucene.util.BitUtil;
-import org.apache.lucene.util.NumericUtils;
+import org.apache.lucene.util.BytesRef;
+
+import java.util.Arrays;
 
 import static org.elasticsearch.common.geo.GeoHashUtils.mortonEncode;
 import static org.elasticsearch.common.geo.GeoHashUtils.stringEncode;
@@ -97,7 +99,8 @@ public final class GeoPoint {
     // todo remove with next release of lucene
     public GeoPoint resetFromIndexableField(IndexableField field) {
         if (field instanceof LatLonPoint) {
-            byte[] bytes = field.binaryValue().bytes;
+            BytesRef br = field.binaryValue();
+            byte[] bytes = Arrays.copyOfRange(br.bytes, br.offset, br.length);
             return this.reset(
                 GeoEncodingUtils.decodeLatitude(bytes, 0),
                 GeoEncodingUtils.decodeLongitude(bytes, Integer.BYTES));

+ 1 - 3
core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointDVIndexFieldData.java

@@ -24,6 +24,7 @@ import org.apache.lucene.index.DocValuesType;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.LeafReader;
 import org.apache.lucene.index.LeafReaderContext;
+import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.common.Nullable;
 import org.elasticsearch.index.Index;
 import org.elasticsearch.index.IndexSettings;
@@ -38,9 +39,6 @@ import org.elasticsearch.search.MultiValueMode;
 
 import java.io.IOException;
 
-/**
- * Created by nknize on 8/23/16.
- */
 public abstract class AbstractLatLonPointDVIndexFieldData extends DocValuesIndexFieldData
     implements IndexGeoPointFieldData {
     AbstractLatLonPointDVIndexFieldData(Index index, String fieldName) {

+ 0 - 3
core/src/main/java/org/elasticsearch/index/fielddata/plain/LatLonPointDVAtomicFieldData.java

@@ -30,9 +30,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 
-/**
- * Created by nknize on 8/23/16.
- */
 final class LatLonPointDVAtomicFieldData extends AbstractAtomicGeoPointFieldData {
     private final SortedNumericDocValues values;
 

+ 3 - 3
core/src/main/java/org/elasticsearch/index/mapper/BaseGeoPointFieldMapper.java

@@ -144,7 +144,7 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
 
         public Y build(Mapper.BuilderContext context) {
             // version 5.0 cuts over to LatLonPoint and no longer indexes geohash, or lat/lon separately
-            if (context.indexCreatedVersion().before(Version.V_5_0_0_alpha6)) {
+            if (context.indexCreatedVersion().before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
                 return buildLegacy(context);
             }
             return build(context, name, fieldType, defaultFieldType, context.indexSettings(),
@@ -203,7 +203,7 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
             Version indexVersionCreated = parserContext.indexVersionCreated();
             if (indexVersionCreated.before(Version.V_2_2_0)) {
                 builder = new LegacyGeoPointFieldMapper.Builder(name);
-            } else if (indexVersionCreated.onOrAfter(Version.V_5_0_0_alpha6)) {
+            } else if (indexVersionCreated.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
                 builder = new LatLonPointFieldMapper.Builder(name);
             } else {
                 builder = new GeoPointFieldMapper.Builder(name);
@@ -214,7 +214,7 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
                 Map.Entry<String, Object> entry = iterator.next();
                 String propName = entry.getKey();
                 Object propNode = entry.getValue();
-                if (indexVersionCreated.before(Version.V_5_0_0_alpha6)) {
+                if (indexVersionCreated.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
                     if (propName.equals("lat_lon")) {
                         deprecationLogger.deprecated(CONTENT_TYPE + " lat_lon parameter is deprecated and will be removed "
                             + "in the next major release");

+ 10 - 2
core/src/main/java/org/elasticsearch/index/mapper/LatLonPointFieldMapper.java

@@ -20,8 +20,10 @@ package org.elasticsearch.index.mapper;
 
 import org.apache.lucene.document.LatLonDocValuesField;
 import org.apache.lucene.document.LatLonPoint;
+import org.apache.lucene.document.StoredField;
 import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.search.Query;
+import org.elasticsearch.Version;
 import org.elasticsearch.common.Explicit;
 import org.elasticsearch.common.geo.GeoPoint;
 import org.elasticsearch.common.geo.GeoUtils;
@@ -36,10 +38,13 @@ import java.util.Iterator;
 import java.util.Map;
 
 /**
- * Created by nknize on 8/23/16.
+ * Field Mapper for geo_point types.
+ *
+ * Uses lucene 6 LatLonPoint encoding
  */
 public class LatLonPointFieldMapper extends BaseGeoPointFieldMapper {
     public static final String CONTENT_TYPE = "geo_point";
+    public static final Version LAT_LON_FIELD_VERSION = Version.V_5_0_0_alpha6;
 
     public static class Defaults extends BaseGeoPointFieldMapper.Defaults {
         public static final LatLonPointFieldType FIELD_TYPE = new LatLonPointFieldType();
@@ -134,9 +139,12 @@ public class LatLonPointFieldMapper extends BaseGeoPointFieldMapper {
         } else {
             GeoUtils.normalizePoint(point);
         }
-        if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) {
+        if (fieldType().indexOptions() != IndexOptions.NONE) {
             context.doc().add(new LatLonPoint(fieldType().name(), point.lat(), point.lon()));
         }
+        if (fieldType().stored()) {
+            context.doc().add(new StoredField(fieldType().name(), point.toString()));
+        }
         if (fieldType.hasDocValues()) {
             context.doc().add(new LatLonDocValuesField(fieldType().name(), point.lat(), point.lon()));
         }

+ 2 - 1
core/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java

@@ -40,6 +40,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
 import org.elasticsearch.index.fielddata.IndexGeoPointFieldData;
 import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper;
 import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper.LegacyGeoPointFieldType;
+import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
 import org.elasticsearch.index.mapper.MappedFieldType;
 import org.elasticsearch.index.search.geo.LegacyInMemoryGeoBoundingBoxQuery;
 import org.elasticsearch.index.search.geo.LegacyIndexedGeoBoundingBoxQuery;
@@ -360,7 +361,7 @@ public class GeoBoundingBoxQueryBuilder extends AbstractQueryBuilder<GeoBounding
             }
         }
 
-        if (indexVersionCreated.onOrAfter(Version.V_5_0_0_alpha6)) {
+        if (indexVersionCreated.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             return LatLonPoint.newBoxQuery(fieldType.name(), luceneBottomRight.getLat(), luceneTopLeft.getLat(),
                 luceneTopLeft.getLon(), luceneBottomRight.getLon());
         } else if (indexVersionCreated.onOrAfter(Version.V_2_2_0)) {

+ 2 - 1
core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryBuilder.java

@@ -39,6 +39,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
 import org.elasticsearch.index.fielddata.IndexGeoPointFieldData;
 import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper;
 import org.elasticsearch.index.mapper.GeoPointFieldMapper;
+import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
 import org.elasticsearch.index.mapper.LegacyGeoPointFieldMapper;
 import org.elasticsearch.index.mapper.MappedFieldType;
 import org.elasticsearch.index.search.geo.GeoDistanceRangeQuery;
@@ -298,7 +299,7 @@ public class GeoDistanceQueryBuilder extends AbstractQueryBuilder<GeoDistanceQue
 
         double normDistance = geoDistance.normalize(this.distance, DistanceUnit.DEFAULT);
 
-        if (indexVersionCreated.onOrAfter(Version.V_5_0_0_alpha6)) {
+        if (indexVersionCreated.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             return LatLonPoint.newDistanceQuery(fieldType.name(), center.lat(), center.lon(), normDistance);
         } else if (indexVersionCreated.before(Version.V_2_2_0)) {
             LegacyGeoPointFieldMapper.LegacyGeoPointFieldType geoFieldType = (LegacyGeoPointFieldMapper.LegacyGeoPointFieldType) fieldType;

+ 2 - 1
core/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryBuilder.java

@@ -39,6 +39,7 @@ import org.elasticsearch.index.fielddata.IndexGeoPointFieldData;
 import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper;
 import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper.LegacyGeoPointFieldType;
 import org.elasticsearch.index.mapper.GeoPointFieldMapper;
+import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
 import org.elasticsearch.index.mapper.MappedFieldType;
 import org.elasticsearch.index.search.geo.GeoDistanceRangeQuery;
 
@@ -347,7 +348,7 @@ public class GeoDistanceRangeQueryBuilder extends AbstractQueryBuilder<GeoDistan
         }
 
         final Version indexVersionCreated = context.indexVersionCreated();
-        if (indexVersionCreated.onOrAfter(Version.V_5_0_0_alpha6)) {
+        if (indexVersionCreated.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             throw new QueryShardException(context, "[{}] queries are no longer supported for geo_point field types. "
                 + "Use geo_distance sort or aggregations", NAME);
         } else if (indexVersionCreated.before(Version.V_2_2_0)) {

+ 8 - 1
core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java

@@ -19,6 +19,8 @@
 
 package org.elasticsearch.index.query;
 
+import org.apache.lucene.document.LatLonPoint;
+import org.apache.lucene.geo.Polygon;
 import org.apache.lucene.search.MatchNoDocsQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.spatial.geopoint.document.GeoPointField;
@@ -36,6 +38,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
 import org.elasticsearch.common.xcontent.XContentParser.Token;
 import org.elasticsearch.index.fielddata.IndexGeoPointFieldData;
 import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper;
+import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
 import org.elasticsearch.index.mapper.MappedFieldType;
 import org.elasticsearch.index.search.geo.GeoPolygonQuery;
 
@@ -210,10 +213,14 @@ public class GeoPolygonQueryBuilder extends AbstractQueryBuilder<GeoPolygonQuery
         double[] lons = new double[shellSize];
         GeoPoint p;
         for (int i=0; i<shellSize; ++i) {
-            p = new GeoPoint(shell.get(i));
+            p = shell.get(i);
             lats[i] = p.lat();
             lons[i] = p.lon();
         }
+
+        if (indexVersionCreated.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
+            return LatLonPoint.newPolygonQuery(fieldType.name(), new Polygon(lats, lons));
+        }
         // if index created V_2_2 use (soon to be legacy) numeric encoding postings format
         // if index created V_2_3 > use prefix encoded postings format
         final GeoPointField.TermEncoding encoding = (indexVersionCreated.before(Version.V_2_3_0)) ?

+ 9 - 3
core/src/test/java/org/elasticsearch/index/mapper/ExternalFieldMapperTests.java

@@ -26,6 +26,7 @@ import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetaData;
 import org.elasticsearch.common.compress.CompressedXContent;
 import org.elasticsearch.common.geo.GeoHashUtils;
+import org.elasticsearch.common.geo.GeoPoint;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.xcontent.XContentFactory;
 import org.elasticsearch.index.IndexService;
@@ -40,6 +41,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import static org.hamcrest.Matchers.closeTo;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
 
@@ -84,7 +86,7 @@ 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(Version.V_5_0_0_alpha6)) {
+        } 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)));
         }
 
@@ -142,8 +144,12 @@ 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(Version.V_5_0_0_alpha6)) {
+        } else if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(Long.parseLong(doc.rootDoc().getField("field.point").stringValue()), is(GeoPointField.encodeLatLon(42.0, 51.0)));
+        } else {
+            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));
         }
 
         IndexableField shape = doc.rootDoc().getField("field.shape");
@@ -212,7 +218,7 @@ 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.before(Version.V_5_0_0_alpha6)) {
+        } else if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(Long.parseLong(doc.rootDoc().getField("field.point").stringValue()), is(GeoPointField.encodeLatLon(42.0, 51.0)));
         }
 

+ 1 - 1
core/src/test/java/org/elasticsearch/index/mapper/ExternalMapper.java

@@ -86,7 +86,7 @@ public class ExternalMapper extends FieldMapper {
             BaseGeoPointFieldMapper pointMapper;
             if (context.indexCreatedVersion().before(Version.V_2_2_0)) {
                 pointMapper = legacyPointBuilder.build(context);
-            } else if (context.indexCreatedVersion().onOrAfter(Version.V_5_0_0_alpha6)) {
+            } else if (context.indexCreatedVersion().onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
                 pointMapper = latLonPointBuilder.build(context);
             } else {
                 pointMapper = pointBuilder.build(context);

+ 35 - 30
core/src/test/java/org/elasticsearch/index/mapper/GeoPointFieldMapperTests.java

@@ -168,7 +168,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
         XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
             .startObject("properties").startObject("point").field("type", "geo_point");
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             xContentBuilder = xContentBuilder.field("lat_lon", true);
         }
         String mapping = xContentBuilder.endObject().endObject().endObject().endObject().string();
@@ -182,7 +182,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
                 .bytes());
 
         assertThat(doc.rootDoc().getField("point"), notNullValue());
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
             assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
         }
@@ -402,7 +402,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         Version version = VersionUtils.randomVersionBetween(random(), Version.CURRENT, Version.CURRENT);
         XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
             .startObject("properties").startObject("point").field("type", "geo_point");
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             xContentBuilder = xContentBuilder.field("lat_lon", true);
         }
         String mapping = xContentBuilder.field("store", true).endObject().endObject().endObject().endObject().string();
@@ -416,8 +416,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
                 .bytes());
 
         assertThat(doc.rootDoc().getField("point"), notNullValue());
-        // TODO LatLonPoint FieldType is private and frozen, need to add ability to store field
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
             assertThat(doc.rootDoc().getField("point.lat").numericValue().doubleValue(), equalTo(1.2));
             assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
@@ -435,7 +434,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
         XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
             .startObject("properties").startObject("point").field("type", "geo_point").field("doc_values", false);
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             xContentBuilder = xContentBuilder.field("lat_lon", true);
         }
         String mapping = xContentBuilder.field("store", true).endObject().endObject().endObject().endObject().string();
@@ -478,7 +477,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
         XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
             .startObject("properties").startObject("point").field("type", "geo_point");
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             xContentBuilder = xContentBuilder.field("lat_lon", true);
         }
         String mapping = xContentBuilder.endObject().endObject().endObject().endObject().string();
@@ -493,7 +492,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
                 .bytes());
 
         assertThat(doc.rootDoc().getField("point"), notNullValue());
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
             assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
             if (version.before(Version.V_2_2_0)) {
@@ -508,7 +507,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
         XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
             .startObject("properties").startObject("point").field("type", "geo_point");
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             xContentBuilder = xContentBuilder.field("lat_lon", true);
         }
         String mapping = xContentBuilder.field("store", true).endObject().endObject().endObject().endObject().string();
@@ -522,7 +521,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
                 .endObject()
                 .bytes());
         assertThat(doc.rootDoc().getField("point"), notNullValue());
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
             assertThat(doc.rootDoc().getField("point.lat").numericValue().doubleValue(), equalTo(1.2));
             assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
@@ -540,7 +539,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
         XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
             .startObject("properties").startObject("point").field("type", "geo_point").field("doc_values", false);
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             xContentBuilder = xContentBuilder.field("lat_lon", true);
         }
         String mapping = xContentBuilder.field("store", true).endObject().endObject().endObject().endObject().string();
@@ -559,23 +558,25 @@ 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.before(Version.V_5_0_0_alpha2)) {
+            assertThat(doc.rootDoc().getFields("point").length, equalTo(2));
             assertThat(doc.rootDoc().getFields("point.lat").length, equalTo(2));
             assertThat(doc.rootDoc().getFields("point.lon").length, equalTo(2));
             assertThat(doc.rootDoc().getFields("point.lat")[0].numericValue().doubleValue(), equalTo(1.2));
             assertThat(doc.rootDoc().getFields("point.lon")[0].numericValue().doubleValue(), equalTo(1.3));
             assertThat(doc.rootDoc().getFields("point.lat")[1].numericValue().doubleValue(), equalTo(1.4));
             assertThat(doc.rootDoc().getFields("point.lon")[1].numericValue().doubleValue(), equalTo(1.5));
+        } else if (version.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
+            assertThat(doc.rootDoc().getFields("point").length, equalTo(4));
         }
         if (version.before(Version.V_2_2_0)) {
             assertThat(doc.rootDoc().getFields("point")[0].stringValue(), equalTo("1.2,1.3"));
-        } else if (version.before(Version.V_5_0_0_alpha6)) {
+        } else if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(GeoPointField.encodeLatLon(1.2, 1.3)));
         }
         if (version.before(Version.V_2_2_0)) {
             assertThat(doc.rootDoc().getFields("point")[1].stringValue(), equalTo("1.4,1.5"));
-        } else if (version.before(Version.V_5_0_0_alpha6)) {
+        } else if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(Long.parseLong(doc.rootDoc().getFields("point")[1].stringValue()), equalTo(GeoPointField.encodeLatLon(1.4, 1.5)));
         }
     }
@@ -584,7 +585,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
         XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
             .startObject("properties").startObject("point").field("type", "geo_point");
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             xContentBuilder = xContentBuilder.field("lat_lon", true);
         }
         String mapping = xContentBuilder.endObject().endObject().endObject().endObject().string();
@@ -598,7 +599,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
                 .bytes());
 
         assertThat(doc.rootDoc().getField("point"), notNullValue());
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
             assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
             if (version.before(Version.V_2_2_0)) {
@@ -614,7 +615,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
             .startArray("dynamic_templates").startObject().startObject("point").field("match", "point*")
             .startObject("mapping").field("type", "geo_point");
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             xContentBuilder = xContentBuilder.field("lat_lon", true);
         }
         String mapping = xContentBuilder.endObject().endObject().endObject().endArray().endObject().endObject().string();
@@ -628,7 +629,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
                 .bytes());
 
         assertThat(doc.rootDoc().getField("point"), notNullValue());
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
             assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
             if (version.before(Version.V_2_2_0)) {
@@ -643,7 +644,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
         XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
             .startObject("properties").startObject("point").field("type", "geo_point");
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             xContentBuilder = xContentBuilder.field("lat_lon", true);
         }
         String mapping = xContentBuilder.field("store", true).endObject().endObject().endObject().endObject().string();
@@ -657,7 +658,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
                 .bytes());
 
         assertThat(doc.rootDoc().getField("point"), notNullValue());
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(doc.rootDoc().getField("point.lat"), notNullValue());
             assertThat(doc.rootDoc().getField("point.lat").numericValue().doubleValue(), equalTo(1.2));
             assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
@@ -667,6 +668,8 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
             } else {
                 assertThat(Long.parseLong(doc.rootDoc().getFields("point")[0].stringValue()), equalTo(GeoPointField.encodeLatLon(1.2, 1.3)));
             }
+        } else {
+            assertThat(doc.rootDoc().getFields("point").length, equalTo(3));
         }
     }
 
@@ -674,7 +677,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
         XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
             .startObject("properties").startObject("point").field("type", "geo_point");
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             xContentBuilder = xContentBuilder.field("lat_lon", true);
         }
         String mapping = xContentBuilder.field("store", true).field("doc_values", false).endObject().endObject()
@@ -692,8 +695,8 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
                 .bytes());
 
         assertThat(doc.rootDoc().getFields("point"), notNullValue());
-        assertThat(doc.rootDoc().getFields("point").length, CoreMatchers.equalTo(2));
         if (version.before(Version.V_5_0_0_alpha2)) {
+            assertThat(doc.rootDoc().getFields("point").length, CoreMatchers.equalTo(2));
             assertThat(doc.rootDoc().getFields("point.lat").length, equalTo(2));
             assertThat(doc.rootDoc().getFields("point.lon").length, equalTo(2));
             assertThat(doc.rootDoc().getFields("point.lat")[0].numericValue().doubleValue(), equalTo(1.2));
@@ -710,6 +713,8 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
             } else {
                 assertThat(Long.parseLong(doc.rootDoc().getFields("point")[1].stringValue()), equalTo(GeoPointField.encodeLatLon(1.4, 1.5)));
             }
+        } else if (version.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
+            assertThat(doc.rootDoc().getFields("point").length, CoreMatchers.equalTo(4));
         }
     }
 
@@ -722,7 +727,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
         DocumentMapperParser parser = createIndex("test", settings).mapperService().documentMapperParser();
         // test deprecation exceptions on newly created indexes
-        if (version.onOrAfter(Version.V_5_0_0_alpha6)) {
+        if (version.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             try {
                 String normalizeMapping = XContentFactory.jsonBuilder().startObject().startObject("type")
                     .startObject("properties").startObject("point").field("type", "geo_point").field("lat_lon", true).endObject().endObject()
@@ -733,7 +738,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
             }
         }
 
-        if (version.onOrAfter(Version.V_5_0_0_alpha6)) {
+        if (version.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             try {
                 String normalizeMapping = XContentFactory.jsonBuilder().startObject().startObject("type")
                     .startObject("properties").startObject("point").field("type", "geo_point").field("geohash", true).endObject().endObject()
@@ -747,7 +752,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         try {
             XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
                 .startObject("properties").startObject("point").field("type", "geo_point");
-            if (version.before(Version.V_5_0_0_alpha6)) {
+            if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
                 xContentBuilder = xContentBuilder.field("lat_lon", true).field("geohash", true);
             }
             String validateMapping = xContentBuilder.field("validate", true).endObject().endObject().endObject().endObject().string();
@@ -760,7 +765,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         try {
             XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
                 .startObject("properties").startObject("point").field("type", "geo_point");
-            if (version.before(Version.V_5_0_0_alpha6)) {
+            if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
                 xContentBuilder = xContentBuilder.field("lat_lon", true).field("geohash", true);
             }
             String validateMapping = xContentBuilder.field("validate_lat", true).endObject().endObject().endObject().endObject().string();
@@ -773,7 +778,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         try {
             XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
                 .startObject("properties").startObject("point").field("type", "geo_point");
-            if (version.before(Version.V_5_0_0_alpha6)) {
+            if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
                 xContentBuilder = xContentBuilder.field("lat_lon", true).field("geohash", true);
             }
             String validateMapping = xContentBuilder.field("validate_lon", true).endObject().endObject().endObject().endObject().string();
@@ -787,7 +792,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         try {
             XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
                 .startObject("properties").startObject("point").field("type", "geo_point");
-            if (version.before(Version.V_5_0_0_alpha6)) {
+            if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
                 xContentBuilder = xContentBuilder.field("lat_lon", true).field("geohash", true);
             }
             String normalizeMapping = xContentBuilder.field("normalize", true).endObject().endObject().endObject().endObject().string();
@@ -800,7 +805,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         try {
             XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
                 .startObject("properties").startObject("point").field("type", "geo_point");
-            if (version.before(Version.V_5_0_0_alpha6)) {
+            if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
                 xContentBuilder = xContentBuilder.field("lat_lon", true).field("geohash", true);
             }
             String normalizeMapping = xContentBuilder.field("normalize_lat", true).endObject().endObject().endObject().endObject().string();
@@ -813,7 +818,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
         try {
             XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type")
                 .startObject("properties").startObject("point").field("type", "geo_point");
-            if (version.before(Version.V_5_0_0_alpha6)) {
+            if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
                 xContentBuilder = xContentBuilder.field("lat_lon", true).field("geohash", true);
             }
             String normalizeMapping = xContentBuilder.field("normalize_lon", true).endObject().endObject().endObject().endObject().string();

+ 3 - 2
core/src/test/java/org/elasticsearch/index/query/GeoDistanceQueryBuilderTests.java

@@ -29,6 +29,7 @@ import org.elasticsearch.common.geo.GeoDistance;
 import org.elasticsearch.common.geo.GeoPoint;
 import org.elasticsearch.common.geo.GeoUtils;
 import org.elasticsearch.common.unit.DistanceUnit;
+import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
 import org.elasticsearch.index.search.geo.GeoDistanceRangeQuery;
 import org.elasticsearch.test.AbstractQueryTestCase;
 import org.elasticsearch.test.geo.RandomShapeGenerator;
@@ -157,7 +158,7 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
 
     private void assertGeoPointQuery(GeoDistanceQueryBuilder queryBuilder, Query query) throws IOException {
         Version version = createShardContext().indexVersionCreated();
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertThat(query, instanceOf(GeoPointDistanceQuery.class));
             GeoPointDistanceQuery geoQuery = (GeoPointDistanceQuery) query;
             assertThat(geoQuery.getField(), equalTo(queryBuilder.fieldName()));
@@ -349,7 +350,7 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase<GeoDista
             assertThat(q.lon(), closeTo(lon, 1E-5D));
             assertThat(q.minInclusiveDistance(), equalTo(Double.NEGATIVE_INFINITY));
             assertThat(q.maxInclusiveDistance(), closeTo(distanceUnit.convert(distance, DistanceUnit.MILES), 1E-5D));
-        } else if (version.before(Version.V_5_0_0_alpha6)) {
+        } else if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             GeoPointDistanceQuery q = (GeoPointDistanceQuery) parsedQuery;
             assertThat(q.getField(), equalTo(GEO_POINT_FIELD_NAME));
             assertThat(q.getCenterLat(), closeTo(lat, 1E-5D));

+ 4 - 3
core/src/test/java/org/elasticsearch/index/query/GeoDistanceRangeQueryTests.java

@@ -29,6 +29,7 @@ import org.elasticsearch.common.geo.GeoDistance;
 import org.elasticsearch.common.geo.GeoPoint;
 import org.elasticsearch.common.geo.GeoUtils;
 import org.elasticsearch.common.unit.DistanceUnit;
+import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
 import org.elasticsearch.index.mapper.MapperService;
 import org.elasticsearch.index.search.geo.GeoDistanceRangeQuery;
 import org.elasticsearch.test.AbstractQueryTestCase;
@@ -204,7 +205,7 @@ public class GeoDistanceRangeQueryTests extends AbstractQueryTestCase<GeoDistanc
     @Override
     public void testToQuery() throws IOException {
         assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
-        if (createShardContext().indexVersionCreated().before(Version.V_5_0_0_alpha6)) {
+        if (createShardContext().indexVersionCreated().before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             super.testToQuery();
         }
     }
@@ -257,7 +258,7 @@ public class GeoDistanceRangeQueryTests extends AbstractQueryTestCase<GeoDistanc
 
     public void testNestedRangeQuery() throws IOException {
         // geo distance range queries are no longer supported in 5.0 they are replaced by using aggregations or sort
-        if (createShardContext().indexVersionCreated().onOrAfter(Version.V_5_0_0_alpha6)) {
+        if (createShardContext().indexVersionCreated().onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             return;
         }
 
@@ -374,7 +375,7 @@ public class GeoDistanceRangeQueryTests extends AbstractQueryTestCase<GeoDistanc
     @Override
     public void testMustRewrite() throws IOException {
         assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
-        if (createShardContext().indexVersionCreated().before(Version.V_5_0_0_alpha6)) {
+        if (createShardContext().indexVersionCreated().before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             super.testMustRewrite();
         }
     }

+ 12 - 3
core/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java

@@ -20,6 +20,8 @@
 package org.elasticsearch.index.query;
 
 import com.vividsolutions.jts.geom.Coordinate;
+import org.apache.lucene.document.LatLonPoint;
+import org.apache.lucene.geo.Polygon;
 import org.apache.lucene.search.MatchNoDocsQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.spatial.geopoint.search.GeoPointInPolygonQuery;
@@ -30,6 +32,7 @@ import org.elasticsearch.common.geo.GeoUtils;
 import org.elasticsearch.common.geo.builders.ShapeBuilder;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
 import org.elasticsearch.index.search.geo.GeoPolygonQuery;
 import org.elasticsearch.test.AbstractQueryTestCase;
 import org.elasticsearch.test.geo.RandomShapeGenerator;
@@ -68,9 +71,10 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase<GeoPolygo
         Version version = context.indexVersionCreated();
         if (version.before(Version.V_2_2_0)) {
             assertLegacyQuery(queryBuilder, query);
-        } else {
+        } else if (version.onOrAfter(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             assertGeoPointQuery(queryBuilder, query);
         }
+        // todo LatLonPointInPolygon is package private
     }
 
     private void assertLegacyQuery(GeoPolygonQueryBuilder queryBuilder, Query query) {
@@ -121,7 +125,9 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase<GeoPolygo
     @Override
     public void testToQuery() throws IOException {
         assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
-        super.testToQuery();
+        if (createShardContext().indexVersionCreated().before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
+            super.testToQuery();
+        }
     }
 
     private static List<GeoPoint> randomPolygon() {
@@ -294,7 +300,7 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase<GeoPolygo
             assertThat(filter.points()[1].lon(), closeTo(-80, 0.00001));
             assertThat(filter.points()[2].lat(), closeTo(20, 0.00001));
             assertThat(filter.points()[2].lon(), closeTo(-90, 0.00001));
-        } else {
+        } else if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             GeoPointInPolygonQuery q = (GeoPointInPolygonQuery) parsedQuery;
             assertThat(q.getField(), equalTo(GEO_POINT_FIELD_NAME));
             assertEquals(1, q.getPolygons().length);
@@ -310,6 +316,9 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase<GeoPolygo
             assertThat(lons[2], closeTo(-90, 1E-5));
             assertThat(lats[3], equalTo(lats[0]));
             assertThat(lons[3], equalTo(lons[0]));
+        } else {
+            // todo LatLonPointInPolygon is package private, need a closeTo check on the query
+            // since some points can be computed from the geohash
         }
     }
 

+ 3 - 2
core/src/test/java/org/elasticsearch/index/query/GeohashCellQueryBuilderTests.java

@@ -29,6 +29,7 @@ import org.elasticsearch.common.geo.GeoPoint;
 import org.elasticsearch.common.unit.DistanceUnit;
 import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper;
 import org.elasticsearch.index.mapper.GeoPointFieldMapper;
+import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
 import org.elasticsearch.index.query.GeohashCellQuery.Builder;
 import org.elasticsearch.test.AbstractQueryTestCase;
 import org.elasticsearch.test.geo.RandomShapeGenerator;
@@ -89,7 +90,7 @@ public class GeohashCellQueryBuilderTests extends AbstractQueryTestCase<Builder>
     public void testToQuery() throws IOException {
         assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
         Version version = createShardContext().indexVersionCreated();
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             super.testToQuery();
         }
     }
@@ -145,7 +146,7 @@ public class GeohashCellQueryBuilderTests extends AbstractQueryTestCase<Builder>
     public void testMustRewrite() throws IOException {
         assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
         Version version = createShardContext().indexVersionCreated();
-        if (version.before(Version.V_5_0_0_alpha6)) {
+        if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
             super.testMustRewrite();
         }
     }

+ 3 - 1
core/src/test/java/org/elasticsearch/index/query/NestedQueryBuilderTests.java

@@ -28,6 +28,7 @@ import org.apache.lucene.search.join.ToParentBlockJoinQuery;
 import org.elasticsearch.Version;
 import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
 import org.elasticsearch.common.compress.CompressedXContent;
+import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
 import org.elasticsearch.index.mapper.MapperService;
 import org.elasticsearch.search.fetch.subphase.InnerHitsContext;
 import org.elasticsearch.search.internal.SearchContext;
@@ -50,7 +51,8 @@ public class NestedQueryBuilderTests extends AbstractQueryTestCase<NestedQueryBu
 
     @Override
     protected void initializeAdditionalMappings(MapperService mapperService) throws IOException {
-        String geoFieldMapping = (mapperService.getIndexSettings().getIndexVersionCreated().before(Version.V_5_0_0_alpha6)) ?
+        String geoFieldMapping = (mapperService.getIndexSettings().getIndexVersionCreated()
+            .before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) ?
             LEGACY_GEO_POINT_FIELD_MAPPING : "type=geo_point";
         mapperService.merge("nested_doc", new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef("nested_doc",
                 STRING_FIELD_NAME, "type=text",

+ 5 - 1
core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java

@@ -21,6 +21,7 @@ package org.elasticsearch.search.geo;
 
 import org.apache.logging.log4j.message.ParameterizedMessage;
 import org.apache.logging.log4j.util.Supplier;
+import org.apache.lucene.geo.GeoEncodingUtils;
 import org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy;
 import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
 import org.apache.lucene.spatial.query.SpatialArgs;
@@ -48,6 +49,7 @@ import org.elasticsearch.common.logging.ESLoggerFactory;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
 import org.elasticsearch.index.query.GeohashCellQuery;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.plugins.Plugin;
@@ -433,8 +435,10 @@ public class GeoFilterIT extends ESIntegTestCase {
             String name = hit.getId();
             if (version.before(Version.V_2_2_0)) {
                 point.resetFromString(hit.fields().get("pin").getValue().toString());
-            } else {
+            } else if (version.before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) {
                 point.resetFromIndexHash(hit.fields().get("pin").getValue());
+            } else {
+                point.resetFromString(hit.getFields().get("pin").getValue());
             }
             double dist = distance(point.getLat(), point.getLon(), 51.11, 9.851);
 

+ 0 - 8
docs/java-api/query-dsl/geo-queries.asciidoc

@@ -30,12 +30,6 @@ The queries in this group are:
 
     Find documents with geo-points within the specified polygon.
 
-<<java-query-dsl-geohash-cell-query,`geohash_cell`>> query::
-
-    Find geo-points whose geohash intersects with the geohash of the specified
-    point.
-
-
 include::geo-shape-query.asciidoc[]
 
 include::geo-bounding-box-query.asciidoc[]
@@ -45,5 +39,3 @@ include::geo-distance-query.asciidoc[]
 include::geo-distance-range-query.asciidoc[]
 
 include::geo-polygon-query.asciidoc[]
-
-include::geohash-cell-query.asciidoc[]

+ 0 - 17
docs/java-api/query-dsl/geohash-cell-query.asciidoc

@@ -1,17 +0,0 @@
-[[java-query-dsl-geohash-cell-query]]
-==== Geohash Cell Query
-
-See {ref}/query-dsl-geohash-cell-query.html[Geohash Cell Query]
-
-[source,java]
---------------------------------------------------
-QueryBuilder qb = geoHashCellQuery("pin.location",  <1>
-            new GeoPoint(13.4080, 52.5186))         <2>
-        .neighbors(true)                            <3>
-        .precision(3);                              <4>
---------------------------------------------------
-<1> field
-<2> point. Can also be a hash like `u30`
-<3> The `neighbors` option of the filter offers the possibility to filter cells
-    next to the given cell.
-<4> precision level

+ 0 - 4
docs/reference/api-conventions.asciidoc

@@ -460,10 +460,6 @@ Centimeter::    `cm` or `centimeters`
 Millimeter::    `mm` or `millimeters`
 Nautical mile:: `NM`, `nmi` or `nauticalmiles`
 
-The `precision` parameter in the <<query-dsl-geohash-cell-query>> accepts
-distances with the above units, but if no unit is specified, then the
-precision is interpreted as the length of the geohash.
-
 [[fuzziness]]
 [float]
 === Fuzziness

+ 0 - 72
docs/reference/mapping/params/geohash-precision.asciidoc

@@ -1,72 +0,0 @@
-[[geohash-precision]]
-=== `geohash_precision`
-
-deprecated[5.0.0, Will be removed in the next major version.]
-
-Geohashes are a form of lat/lon encoding which divides the earth up into
-a grid. Each cell in this grid is represented by a geohash string. Each
-cell in turn can be further subdivided into smaller cells which are
-represented by a longer string. So the longer the geohash, the smaller
-(and thus more accurate) the cell is.
-
-The `geohash_precision` setting controls the length of the geohash that is
-indexed when the <<geohash,`geohash`>> option is enabled, and the maximum
-geohash length when the <<geohash-prefix,`geohash_prefix`>> option is enabled.
-
-It accepts:
-
-* a number between 1 and 12 (default), which represents the length of the geohash.
-* a <<distance-units,distance>>, e.g. `1km`.
-
-If a distance is specified, it will be translated to the smallest
-geohash-length that will provide the requested resolution.
-
-For example, using this mapping:
-
-[source,js]
---------------------------------------------------
-PUT my_index
-{
-  "mappings": {
-    "my_type": {
-      "properties": {
-        "location": {
-          "type": "geo_point",
-          "geohash_prefix": true,
-          "geohash_precision": 6 <1>
-        }
-      }
-    }
-  }
-}
---------------------------------------------------
-// CONSOLE
-// TEST[warning:geo_point geohash_precision parameter is deprecated and will be removed in the next major release]
-// TEST[warning:geo_point geohash_prefix parameter is deprecated and will be removed in the next major release]
-// TEST[warning:geo_point geohash parameter is deprecated and will be removed in the next major release]
-
-You can issue this index and query:
-[source,js]
---------------------------------------------------
-PUT my_index/my_type/1?refresh
-{
-  "location": {
-    "lat": 41.12,
-    "lon": -71.34
-  }
-}
-
-GET my_index/_search?fielddata_fields=location.geohash
-{
-  "query": {
-    "term": {
-      "location.geohash": "drm3bt"
-    }
-  }
-}
-
---------------------------------------------------
-// CONSOLE
-// TEST[continued]
-
-<1> A `geohash_precision` of 6 equates to geohash cells of approximately 1.26km x 0.6km

+ 0 - 74
docs/reference/mapping/params/geohash-prefix.asciidoc

@@ -1,74 +0,0 @@
-[[geohash-prefix]]
-=== `geohash_prefix`
-
-deprecated[5.0.0, Will be removed in the next major version.]
-
-
-Geohashes are a form of lat/lon encoding which divides the earth up into
-a grid. Each cell in this grid is represented by a geohash string. Each
-cell in turn can be further subdivided into smaller cells which are
-represented by a longer string. So the longer the geohash, the smaller
-(and thus more accurate) the cell is.
-
-While the <<geohash,`geohash`>> option enables indexing the geohash that
-corresponds to the lat/lon point, at the specified
-<<geohash-precision,precision>>, the `geohash_prefix` option will also
-index all the enclosing cells as well.
-
-For instance, a geohash of `drm3btev3e86` will index all of the following
-terms: [ `d`, `dr`, `drm`, `drm3`, `drm3b`, `drm3bt`, `drm3bte`, `drm3btev`,
-`drm3btev3`, `drm3btev3e`, `drm3btev3e8`, `drm3btev3e86` ].
-
-The geohash prefixes can be used with the
-<<query-dsl-geohash-cell-query,`geohash_cell` query>> to find points within a
-particular geohash, or its neighbours:
-
-
-[source,js]
---------------------------------------------------
-PUT my_index
-{
-  "mappings": {
-    "my_type": {
-      "properties": {
-        "location": {
-          "type": "geo_point",
-          "geohash_prefix": true,
-          "geohash_precision": 6
-        }
-      }
-    }
-  }
-}
---------------------------------------------------
-// CONSOLE
-// TEST[warning:geo_point geohash_precision parameter is deprecated and will be removed in the next major release]
-// TEST[warning:geo_point geohash_prefix parameter is deprecated and will be removed in the next major release]
-// TEST[warning:geo_point geohash parameter is deprecated and will be removed in the next major release]
-
-[source,js]
---------------------------------------------------
-PUT my_index/my_type/1
-{
-  "location": {
-    "lat": 41.12,
-    "lon": -71.34
-  }
-}
-
-GET my_index/_search?fielddata_fields=location.geohash
-{
-  "query": {
-    "geohash_cell": {
-      "location": {
-        "lat": 41.02,
-        "lon": -71.48
-      },
-      "precision": 4, <1>
-      "neighbors": true <1>
-    }
-  }
-}
---------------------------------------------------
-// CONSOLE
-// TEST[continued]

+ 0 - 78
docs/reference/mapping/params/geohash.asciidoc

@@ -1,78 +0,0 @@
-[[geohash]]
-=== `geohash`
-
-deprecated[5.0.0, Will be removed in the next major version.]
-
-Geohashes are a form of lat/lon encoding which divides the earth up into
-a grid. Each cell in this grid is represented by a geohash string. Each
-cell in turn can be further subdivided into smaller cells which are
-represented by a longer string. So the longer the geohash, the smaller
-(and thus more accurate) the cell is.
-
-Because geohashes are just strings, they can be stored in an inverted
-index like any other string, which makes querying them very efficient.
-
-If you enable the `geohash` option, a `geohash` ``sub-field'' will be indexed
-as, eg `.geohash`. The length of the geohash is controlled by the
-<<geohash-precision,`geohash_precision`>> parameter.
-
-If the <<geohash-prefix,`geohash_prefix`>> option is enabled, the `geohash`
-option will be enabled automatically.
-
-For example, with this mapping:
-
-[source,js]
---------------------------------------------------
-PUT my_index
-{
-  "mappings": {
-    "my_type": {
-      "properties": {
-        "location": {
-          "type": "geo_point", <1>
-          "geohash": true
-        }
-      }
-    }
-  }
-}
---------------------------------------------------
-// CONSOLE
-// TEST[warning:geo_point geohash parameter is deprecated and will be removed in the next major release]
-
-You can index a document and use this query:
-
-[source,js]
---------------------------------------------------
-PUT my_index/my_type/1?refresh
-{
-  "location": {
-    "lat": 41.12,
-    "lon": -71.34
-  }
-}
-
-GET my_index/_search?fielddata_fields=location.geohash <2>
-{
-  "query": {
-    "prefix": {
-      "location.geohash": "drm3b" <3>
-    }
-  }
-}
---------------------------------------------------
-// CONSOLE
-// TEST[continued]
-
-<1> A `location.geohash` field will be indexed for each geo-point.
-<2> The geohash can be retrieved with <<doc-values,`doc_values`>>.
-<3> A <<query-dsl-prefix-query,`prefix`>> query can find all geohashes which start with a particular prefix.
-
-[WARNING]
-============================================
-
-A `prefix` query on geohashes is expensive.  Instead, consider using the
-<<geohash-prefix,`geohash_prefix`>> to pay the expense once at index time
-instead of on every query.
-
-============================================

+ 0 - 80
docs/reference/mapping/params/lat-lon.asciidoc

@@ -1,80 +0,0 @@
-[[lat-lon]]
-=== `lat_lon`
-
-deprecated[5.0.0, ????????]
-// https://github.com/elastic/elasticsearch/issues/19792
-
-<<geo-queries,Geo-queries>> are usually performed by plugging the value of
-each <<geo-point,`geo_point`>> field into a formula to determine whether it
-falls into the required area or not. Unlike most queries, the inverted index
-is not involved.
-
-Setting `lat_lon` to `true` causes the latitude and longitude values to be
-indexed as numeric fields (called `.lat` and `.lon`). These fields can be used
-by the <<query-dsl-geo-bounding-box-query,`geo_bounding_box`>> and
-<<query-dsl-geo-distance-query,`geo_distance`>> queries instead of
-performing in-memory calculations. So this mapping:
-
-[source,js]
---------------------------------------------------
-PUT my_index
-{
-  "mappings": {
-    "my_type": {
-      "properties": {
-        "location": {
-          "type": "geo_point",
-          "lat_lon": true <1>
-        }
-      }
-    }
-  }
-}
---------------------------------------------------
-// CONSOLE
-// TEST[warning:geo_point lat_lon parameter is deprecated and will be removed in the next major release]
-<1> Setting `lat_lon` to true indexes the geo-point in the `location.lat` and `location.lon` fields.
-
-With this document:
-
-[source,js]
---------------------------------------------------
-PUT my_index/my_type/1?refresh
-{
-  "location": {
-    "lat": 41.12,
-    "lon": -71.34
-  }
-}
---------------------------------------------------
-// CONSOLE
-// TEST[continued]
-
-Allows this query:
-
-[source,js]
---------------------------------------------------
-GET my_index/_search
-{
-  "query": {
-    "geo_distance": {
-      "location": {
-        "lat": 41,
-        "lon": -71
-      },
-      "distance": "50km",
-      "optimize_bbox": "indexed" <1>
-    }
-  }
-}
---------------------------------------------------
-// CONSOLE
-// TEST[continued]
-// TEST[warning:Deprecated field [optimize_bbox] used, replaced by [no replacement: `optimize_bbox` is no longer supported due to recent improvements]]
-<1> The `indexed` option tells the geo-distance query to use the inverted index instead of the in-memory calculation.
-
-Whether the in-memory or indexed operation performs better depends both on
-your dataset and on the types of queries that you are running.
-
-NOTE: The `lat_lon` option only makes sense for single-value `geo_point`
-fields. It will not work with arrays of geo-points.

+ 1 - 2
docs/reference/mapping/types/geo-point.asciidoc

@@ -5,8 +5,7 @@ Fields of type `geo_point` accept latitude-longitude pairs, which can be used:
 
 * to find geo-points within a <<query-dsl-geo-bounding-box-query,bounding box>>,
   within a certain <<query-dsl-geo-distance-query,distance>> of a central point,
-  within a <<query-dsl-geo-polygon-query,polygon>>, or within a
-  <<query-dsl-geohash-cell-query,geohash>> cell.
+  or within a <<query-dsl-geo-polygon-query,polygon>>.
 * to aggregate documents by <<search-aggregations-bucket-geohashgrid-aggregation,geographically>>
   or by <<search-aggregations-bucket-geodistance-aggregation,distance>> from a central point.
 * to integrate distance into a document's <<query-dsl-function-score-query,relevance score>>.

+ 0 - 7
docs/reference/query-dsl/geo-queries.asciidoc

@@ -31,11 +31,6 @@ The queries in this group are:
 
     Find documents with geo-points within the specified polygon.
 
-<<query-dsl-geohash-cell-query,`geohash_cell`>> query::
-
-    Find geo-points whose geohash intersects with the geohash of the specified
-    point.
-
 
 include::geo-shape-query.asciidoc[]
 
@@ -46,5 +41,3 @@ include::geo-distance-query.asciidoc[]
 include::geo-distance-range-query.asciidoc[]
 
 include::geo-polygon-query.asciidoc[]
-
-include::geohash-cell-query.asciidoc[]

+ 0 - 81
docs/reference/query-dsl/geohash-cell-query.asciidoc

@@ -1,81 +0,0 @@
-[[query-dsl-geohash-cell-query]]
-=== Geohash Cell Query
-
-The `geohash_cell` query provides access to a hierarchy of geohashes.
-By defining a geohash cell, only <<geo-point,geopoints>>
-within this cell will match this filter.
-
-To get this filter work all prefixes of a geohash need to be indexed. In
-example a geohash `u30` needs to be decomposed into three terms: `u30`,
-`u3` and `u`. This decomposition must be enabled in the mapping of the
-<<geo-point,geopoint>> field that's going to be filtered by
-setting the `geohash_prefix` option:
-
-[source,js]
---------------------------------------------------
-PUT /my_index
-{
-    "mappings" : {
-        "location": {
-            "properties": {
-                "pin": {
-                    "type": "geo_point",
-                    "geohash": true,
-                    "geohash_prefix": true,
-                    "geohash_precision": 10
-                }
-            }
-        }
-    }
-}
---------------------------------------------------
-// CONSOLE
-// TEST[warning:geo_point geohash parameter is deprecated and will be removed in the next major release]
-// TEST[warning:geo_point geohash_precision parameter is deprecated and will be removed in the next major release]
-// TEST[warning:geo_point geohash_prefix parameter is deprecated and will be removed in the next major release]
-
-The geohash cell can defined by all formats of `geo_points`. If such a cell is
-defined by a latitude and longitude pair the size of the cell needs to be
-setup. This can be done by the `precision` parameter of the filter. This
-parameter can be set to an integer value which sets the length of the geohash
-prefix. Instead of setting a geohash length directly it is also possible to
-define the precision as distance, in example `"precision": "50m"`. (See
-<<distance-units>>.)
-
-The `neighbor` option of the filter offers the possibility to filter cells
-next to the given cell.
-
-[source,js]
---------------------------------------------------
-GET /_search
-{
-    "query": {
-        "bool" : {
-            "must" : {
-                "match_all" : {}
-            },
-            "filter" : {
-                "geohash_cell": {
-                    "pin": {
-                        "lat": 13.4080,
-                        "lon": 52.5186
-                    },
-                    "precision": 3,
-                    "neighbors": true
-                }
-            }
-        }
-    }
-}
---------------------------------------------------
-// CONSOLE
-// TEST[continued]
-
-[float]
-==== Ignore Unmapped
-
-When set to `true` the `ignore_unmapped` option will ignore an unmapped field
-and will not match any documents for this query. This can be useful when
-querying multiple indexes which might have different mappings. When set to
-`false` (the default value) the query will throw an exception if the field
-is not mapped.

+ 0 - 7
docs/reference/redirects.asciidoc

@@ -131,13 +131,6 @@ The `geo_shape` filter has been replaced by the <<query-dsl-geo-shape-query>>.
 It behaves as a query in ``query context'' and as a filter in ``filter
 context'' (see <<query-dsl>>).
 
-[role="exclude",id="query-dsl-geohash-cell-filter"]
-=== Geohash Cell Filter
-
-The `geohash_cell` filter has been replaced by the <<query-dsl-geohash-cell-query>>.
-It behaves as a query in ``query context'' and as a filter in ``filter
-context'' (see <<query-dsl>>).
-
 [role="exclude",id="query-dsl-has-child-filter"]
 === Has Child Filter
 

+ 2 - 1
test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java

@@ -74,6 +74,7 @@ import org.elasticsearch.index.analysis.AnalysisService;
 import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
 import org.elasticsearch.index.fielddata.IndexFieldDataCache;
 import org.elasticsearch.index.fielddata.IndexFieldDataService;
+import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
 import org.elasticsearch.index.mapper.MapperService;
 import org.elasticsearch.index.query.AbstractQueryBuilder;
 import org.elasticsearch.index.query.QueryBuilder;
@@ -1100,7 +1101,7 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
             });
             indicesQueriesRegistry = injector.getInstance(IndicesQueriesRegistry.class);
 
-            String geoFieldMapping = (idxSettings.getIndexVersionCreated().before(Version.V_5_0_0_alpha6)) ?
+            String geoFieldMapping = (idxSettings.getIndexVersionCreated().before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) ?
                 LEGACY_GEO_POINT_FIELD_MAPPING : "type=geo_point";
 
             for (String type : currentTypes) {