summaryrefslogtreecommitdiff
path: root/core/src/main/java/org
diff options
context:
space:
mode:
authorNicholas Knize <nknize@gmail.com>2017-02-03 15:14:11 -0600
committerNicholas Knize <nknize@gmail.com>2017-02-06 14:17:21 -0600
commit1c9fdfd1b34916965d646978c2d2dbc159edf247 (patch)
tree619eff3b11df32a87a5beccccb67e9eba9342652 /core/src/main/java/org
parent033f03109fd3d541fa41a61697dd4b4906aa5fc2 (diff)
Remove GeoPointFieldMapper abstraction
In order to support the evolving GeoPoint encodings in Lucene 5 and 6, ES 2.x and 5.x implements an abstraction layer to the GeoPointFieldMapper classes. As of 5.x the geo_point field mapper settled on using Lucene's more performant LatLonPoint field type and deprecated all other encodings. In 6.0 all encodings except LatLonPoint have been removed rendering this abstraction layer useless. This commit removes the abstraction layer and renames the LatLonPointFieldMapper back to GeoPointFieldMapper to mantain consistency with ES field naming.
Diffstat (limited to 'core/src/main/java/org')
-rw-r--r--core/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java (renamed from core/src/main/java/org/elasticsearch/index/mapper/BaseGeoPointFieldMapper.java)239
-rw-r--r--core/src/main/java/org/elasticsearch/index/mapper/LatLonPointFieldMapper.java179
-rw-r--r--core/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java4
-rw-r--r--core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryBuilder.java4
-rw-r--r--core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java4
-rw-r--r--core/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionBuilder.java4
-rw-r--r--core/src/main/java/org/elasticsearch/indices/IndicesModule.java7
-rw-r--r--core/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java4
8 files changed, 139 insertions, 306 deletions
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/BaseGeoPointFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java
index f09d841ec9..f992683200 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/BaseGeoPointFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java
@@ -16,34 +16,30 @@
* specific language governing permissions and limitations
* under the License.
*/
-
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.geo.GeoEncodingUtils;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexableField;
-import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.IndexOptions;
+import org.apache.lucene.index.PointValues;
import org.apache.lucene.search.Query;
-import org.apache.lucene.util.NumericUtils;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.fieldstats.FieldStats;
import org.elasticsearch.common.Explicit;
-import org.elasticsearch.common.Nullable;
-import org.elasticsearch.common.geo.GeoHashUtils;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.geo.GeoUtils;
-import org.elasticsearch.common.logging.DeprecationLogger;
-import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.index.fielddata.IndexFieldData;
-import org.elasticsearch.index.fielddata.plain.AbstractGeoPointDVIndexFieldData;
+import org.elasticsearch.index.fielddata.plain.AbstractLatLonPointDVIndexFieldData;
import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.index.query.QueryShardException;
-import org.elasticsearch.search.DocValueFormat;
-import org.joda.time.DateTimeZone;
import java.io.IOException;
import java.util.Iterator;
@@ -53,42 +49,38 @@ import java.util.Map;
import static org.elasticsearch.index.mapper.TypeParsers.parseField;
/**
- * GeoPointFieldMapper base class to maintain backward compatibility
+ * Field Mapper for geo_point types.
+ *
+ * Uses lucene 6 LatLonPoint encoding
*/
-public abstract class BaseGeoPointFieldMapper extends FieldMapper implements ArrayValueMapperParser {
+public class GeoPointFieldMapper extends FieldMapper implements ArrayValueMapperParser {
public static final String CONTENT_TYPE = "geo_point";
- protected static final DeprecationLogger deprecationLogger = new DeprecationLogger(Loggers.getLogger(BaseGeoPointFieldMapper.class));
+
public static class Names {
- public static final String LAT = "lat";
- public static final String LAT_SUFFIX = "." + LAT;
- public static final String LON = "lon";
- public static final String LON_SUFFIX = "." + LON;
- public static final String GEOHASH = "geohash";
public static final String IGNORE_MALFORMED = "ignore_malformed";
}
public static class Defaults {
- public static final boolean ENABLE_LATLON = false;
- public static final boolean ENABLE_GEOHASH = false;
- public static final boolean ENABLE_GEOHASH_PREFIX = false;
- public static final int GEO_HASH_PRECISION = GeoHashUtils.PRECISION;
public static final Explicit<Boolean> IGNORE_MALFORMED = new Explicit<>(false, false);
- }
+ public static final GeoPointFieldType FIELD_TYPE = new GeoPointFieldType();
- public abstract static class Builder<T extends Builder, Y extends BaseGeoPointFieldMapper> extends FieldMapper.Builder<T, Y> {
+ static {
+ FIELD_TYPE.setTokenized(false);
+ FIELD_TYPE.setHasDocValues(true);
+ FIELD_TYPE.setDimensions(2, Integer.BYTES);
+ FIELD_TYPE.freeze();
+ }
+ }
+ public static class Builder extends FieldMapper.Builder<Builder, GeoPointFieldMapper> {
protected Boolean ignoreMalformed;
- public Builder(String name, MappedFieldType fieldType) {
- super(name, fieldType, fieldType);
+ public Builder(String name) {
+ super(name, Defaults.FIELD_TYPE, Defaults.FIELD_TYPE);
+ builder = this;
}
- @Override
- public GeoPointFieldType fieldType() {
- return (GeoPointFieldType)fieldType;
- }
-
- public T ignoreMalformed(boolean ignoreMalformed) {
+ public Builder ignoreMalformed(boolean ignoreMalformed) {
this.ignoreMalformed = ignoreMalformed;
return builder;
}
@@ -100,23 +92,30 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
if (context.indexSettings() != null) {
return new Explicit<>(IGNORE_MALFORMED_SETTING.get(context.indexSettings()), false);
}
- return Defaults.IGNORE_MALFORMED;
+ return GeoPointFieldMapper.Defaults.IGNORE_MALFORMED;
}
- public abstract Y build(BuilderContext context, String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
- Settings indexSettings, FieldMapper latMapper, FieldMapper lonMapper,
- FieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed, CopyTo copyTo);
+ public GeoPointFieldMapper build(BuilderContext context, String simpleName, MappedFieldType fieldType,
+ MappedFieldType defaultFieldType, Settings indexSettings,
+ MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
+ CopyTo copyTo) {
+ setupFieldType(context);
+ return new GeoPointFieldMapper(simpleName, fieldType, defaultFieldType, indexSettings, multiFields,
+ ignoreMalformed, copyTo);
+ }
- public Y build(Mapper.BuilderContext context) {
+ @Override
+ public GeoPointFieldMapper build(BuilderContext context) {
return build(context, name, fieldType, defaultFieldType, context.indexSettings(),
- null, null, null, multiFieldsBuilder.build(this, context), ignoreMalformed(context), copyTo);
+ multiFieldsBuilder.build(this, context), ignoreMalformed(context), copyTo);
}
}
- public abstract static class TypeParser implements Mapper.TypeParser {
+ public static class TypeParser implements Mapper.TypeParser {
@Override
- public Mapper.Builder<?, ?> parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
- Builder<?, ?> builder = new LatLonPointFieldMapper.Builder(name);
+ public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext)
+ throws MapperParsingException {
+ Builder builder = new GeoPointFieldMapper.Builder(name);
parseField(builder, name, node, parserContext);
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
@@ -134,9 +133,37 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
}
}
- public static class GeoPointFieldType extends MappedFieldType {
+ protected Explicit<Boolean> ignoreMalformed;
+
+ public GeoPointFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
+ Settings indexSettings, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
+ CopyTo copyTo) {
+ super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
+ this.ignoreMalformed = ignoreMalformed;
+ }
+
+ @Override
+ protected void doMerge(Mapper mergeWith, boolean updateAllTypes) {
+ super.doMerge(mergeWith, updateAllTypes);
+ GeoPointFieldMapper gpfmMergeWith = (GeoPointFieldMapper) mergeWith;
+ if (gpfmMergeWith.ignoreMalformed.explicit()) {
+ this.ignoreMalformed = gpfmMergeWith.ignoreMalformed;
+ }
+ }
- GeoPointFieldType() {}
+ @Override
+ protected String contentType() {
+ return CONTENT_TYPE;
+ }
+
+ @Override
+ protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException {
+ throw new UnsupportedOperationException("Parsing is implemented in parse(), this method should NEVER be called");
+ }
+
+ public static class GeoPointFieldType extends MappedFieldType {
+ GeoPointFieldType() {
+ }
GeoPointFieldType(GeoPointFieldType ref) {
super(ref);
@@ -154,75 +181,64 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
@Override
public IndexFieldData.Builder fielddataBuilder() {
- return new AbstractGeoPointDVIndexFieldData.Builder();
- }
-
- @Override
- public DocValueFormat docValueFormat(@Nullable String format, DateTimeZone timeZone) {
- if (format != null) {
- throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] does not support custom formats");
- }
- if (timeZone != null) {
- throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName()
- + "] does not support custom time zones");
- }
- return DocValueFormat.GEOHASH;
+ failIfNoDocValues();
+ return new AbstractLatLonPointDVIndexFieldData.Builder();
}
@Override
public Query termQuery(Object value, QueryShardContext context) {
- throw new QueryShardException(context, "Geo fields do not support exact searching, use dedicated geo queries instead: [" + name() + "]");
+ throw new QueryShardException(context, "Geo fields do not support exact searching, use dedicated geo queries instead: ["
+ + name() + "]");
}
@Override
public FieldStats.GeoPoint stats(IndexReader reader) throws IOException {
String field = name();
- FieldInfo fi = org.apache.lucene.index.MultiFields.getMergedFieldInfos(reader).fieldInfo(field);
+ FieldInfo fi = org.apache.lucene.index.MultiFields.getMergedFieldInfos(reader).fieldInfo(name());
if (fi == null) {
return null;
}
-
- Terms terms = org.apache.lucene.index.MultiFields.getTerms(reader, field);
- if (terms == null) {
- return new FieldStats.GeoPoint(reader.maxDoc(), 0L, -1L, -1L, isSearchable(), isAggregatable());
+ final long size = PointValues.size(reader, field);
+ if (size == 0) {
+ return new FieldStats.GeoPoint(reader.maxDoc(), -1L, -1L, -1L, isSearchable(), isAggregatable());
}
- GeoPoint minPt = GeoPoint.fromGeohash(NumericUtils.sortableBytesToLong(terms.getMin().bytes, terms.getMin().offset));
- GeoPoint maxPt = GeoPoint.fromGeohash(NumericUtils.sortableBytesToLong(terms.getMax().bytes, terms.getMax().offset));
- return new FieldStats.GeoPoint(reader.maxDoc(), terms.getDocCount(), -1L, terms.getSumTotalTermFreq(), isSearchable(),
- isAggregatable(), minPt, maxPt);
+ final int docCount = PointValues.getDocCount(reader, field);
+ byte[] min = PointValues.getMinPackedValue(reader, field);
+ byte[] max = PointValues.getMaxPackedValue(reader, field);
+ GeoPoint minPt = new GeoPoint(GeoEncodingUtils.decodeLatitude(min, 0), GeoEncodingUtils.decodeLongitude(min, Integer.BYTES));
+ GeoPoint maxPt = new GeoPoint(GeoEncodingUtils.decodeLatitude(max, 0), GeoEncodingUtils.decodeLongitude(max, Integer.BYTES));
+ return new FieldStats.GeoPoint(reader.maxDoc(), docCount, -1L, size, isSearchable(), isAggregatable(),
+ minPt, maxPt);
}
}
- protected Explicit<Boolean> ignoreMalformed;
-
- protected BaseGeoPointFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings,
- FieldMapper latMapper, FieldMapper lonMapper, FieldMapper geoHashMapper,
- MultiFields multiFields, Explicit<Boolean> ignoreMalformed, CopyTo copyTo) {
- super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
- this.ignoreMalformed = ignoreMalformed;
- }
+ protected void parse(ParseContext originalContext, GeoPoint point) throws IOException {
+ // Geopoint fields, by default, will not be included in _all
+ final ParseContext context = originalContext.setIncludeInAllDefault(false);
- @Override
- protected void doMerge(Mapper mergeWith, boolean updateAllTypes) {
- super.doMerge(mergeWith, updateAllTypes);
- BaseGeoPointFieldMapper gpfmMergeWith = (BaseGeoPointFieldMapper) mergeWith;
- if (gpfmMergeWith.ignoreMalformed.explicit()) {
- this.ignoreMalformed = gpfmMergeWith.ignoreMalformed;
+ if (ignoreMalformed.value() == false) {
+ if (point.lat() > 90.0 || point.lat() < -90.0) {
+ throw new IllegalArgumentException("illegal latitude value [" + point.lat() + "] for " + name());
+ }
+ if (point.lon() > 180.0 || point.lon() < -180) {
+ throw new IllegalArgumentException("illegal longitude value [" + point.lon() + "] for " + name());
+ }
+ } else {
+ GeoUtils.normalizePoint(point);
+ }
+ 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()));
+ }
+ // if the mapping contains multifields then use the geohash string
+ if (multiFields.iterator().hasNext()) {
+ multiFields.parse(this, context.createExternalValueContext(point.geohash()));
}
- }
-
- @Override
- protected String contentType() {
- return CONTENT_TYPE;
- }
-
- @Override
- protected void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException {
- throw new UnsupportedOperationException("Parsing is implemented in parse(), this method should NEVER be called");
- }
-
- protected void parse(ParseContext context, GeoPoint point, String geoHash) throws IOException {
- multiFields.parse(this, context.createExternalValueContext(point));
}
@Override
@@ -232,7 +248,7 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
GeoPoint sparse = context.parseExternalValue(GeoPoint.class);
if (sparse != null) {
- parse(context, sparse, null);
+ parse(context, sparse);
} else {
sparse = new GeoPoint();
XContentParser.Token token = context.parser().currentToken();
@@ -241,14 +257,14 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
if (token == XContentParser.Token.START_ARRAY) {
// its an array of array of lon/lat [ [1.2, 1.3], [1.4, 1.5] ]
while (token != XContentParser.Token.END_ARRAY) {
- try {
- parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse), null);
- } catch (ElasticsearchParseException e) {
- if (ignoreMalformed.value() == false) {
- throw e;
- }
- }
- token = context.parser().nextToken();
+ try {
+ parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse));
+ } catch (ElasticsearchParseException e) {
+ if (ignoreMalformed.value() == false) {
+ throw e;
+ }
+ }
+ token = context.parser().nextToken();
}
} else {
// its an array of other possible values
@@ -257,21 +273,21 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
token = context.parser().nextToken();
double lat = context.parser().doubleValue();
while ((token = context.parser().nextToken()) != XContentParser.Token.END_ARRAY);
- parse(context, sparse.reset(lat, lon), null);
+ parse(context, sparse.reset(lat, lon));
} else {
while (token != XContentParser.Token.END_ARRAY) {
if (token == XContentParser.Token.VALUE_STRING) {
parsePointFromString(context, sparse, context.parser().text());
} else {
try {
- parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse), null);
+ parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse));
} catch (ElasticsearchParseException e) {
if (ignoreMalformed.value() == false) {
throw e;
}
}
}
- token = context.parser().nextToken();
+ token = context.parser().nextToken();
}
}
}
@@ -279,7 +295,7 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
parsePointFromString(context, sparse, context.parser().text());
} else if (token != XContentParser.Token.VALUE_NULL) {
try {
- parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse), null);
+ parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse));
} catch (ElasticsearchParseException e) {
if (ignoreMalformed.value() == false) {
throw e;
@@ -294,9 +310,9 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
private void parsePointFromString(ParseContext context, GeoPoint sparse, String point) throws IOException {
if (point.indexOf(',') < 0) {
- parse(context, sparse.resetFromGeoHash(point), point);
+ parse(context, sparse.resetFromGeoHash(point));
} else {
- parse(context, sparse.resetFromString(point), null);
+ parse(context, sparse.resetFromString(point));
}
}
@@ -304,8 +320,7 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {
super.doXContentBody(builder, includeDefaults, params);
if (includeDefaults || ignoreMalformed.explicit()) {
- builder.field(Names.IGNORE_MALFORMED, ignoreMalformed.value());
+ builder.field(GeoPointFieldMapper.Names.IGNORE_MALFORMED, ignoreMalformed.value());
}
}
-
}
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/LatLonPointFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/LatLonPointFieldMapper.java
deleted file mode 100644
index 919f6590c1..0000000000
--- a/core/src/main/java/org/elasticsearch/index/mapper/LatLonPointFieldMapper.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-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.geo.GeoEncodingUtils;
-import org.apache.lucene.index.FieldInfo;
-import org.apache.lucene.index.IndexOptions;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.PointValues;
-import org.apache.lucene.search.Query;
-import org.elasticsearch.action.fieldstats.FieldStats;
-import org.elasticsearch.common.Explicit;
-import org.elasticsearch.common.geo.GeoPoint;
-import org.elasticsearch.common.geo.GeoUtils;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.index.fielddata.IndexFieldData;
-import org.elasticsearch.index.fielddata.plain.AbstractLatLonPointDVIndexFieldData;
-import org.elasticsearch.index.query.QueryShardContext;
-import org.elasticsearch.index.query.QueryShardException;
-
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * 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 class Defaults extends BaseGeoPointFieldMapper.Defaults {
- public static final LatLonPointFieldType FIELD_TYPE = new LatLonPointFieldType();
-
- static {
- FIELD_TYPE.setTokenized(false);
- FIELD_TYPE.setHasDocValues(true);
- FIELD_TYPE.setDimensions(2, Integer.BYTES);
- FIELD_TYPE.freeze();
- }
- }
-
- public static class Builder extends BaseGeoPointFieldMapper.Builder<Builder, LatLonPointFieldMapper> {
- public Builder(String name) {
- super(name, Defaults.FIELD_TYPE);
- builder = this;
- }
-
- @Override
- public LatLonPointFieldMapper build(BuilderContext context, String simpleName, MappedFieldType fieldType,
- MappedFieldType defaultFieldType, Settings indexSettings,
- FieldMapper latMapper, FieldMapper lonMapper, FieldMapper geoHashMapper,
- MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
- CopyTo copyTo) {
- setupFieldType(context);
- return new LatLonPointFieldMapper(simpleName, fieldType, defaultFieldType, indexSettings, multiFields,
- ignoreMalformed, copyTo);
- }
-
- @Override
- public LatLonPointFieldMapper build(BuilderContext context) {
- return super.build(context);
- }
- }
-
- public static class TypeParser extends BaseGeoPointFieldMapper.TypeParser {
- @Override
- public Mapper.Builder<?, ?> parse(String name, Map<String, Object> node, ParserContext parserContext)
- throws MapperParsingException {
- return super.parse(name, node, parserContext);
- }
- }
-
- public LatLonPointFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
- Settings indexSettings, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
- CopyTo copyTo) {
- super(simpleName, fieldType, defaultFieldType, indexSettings, null, null, null, multiFields, ignoreMalformed, copyTo);
- }
-
- public static class LatLonPointFieldType extends GeoPointFieldType {
- LatLonPointFieldType() {
- }
-
- LatLonPointFieldType(LatLonPointFieldType ref) {
- super(ref);
- }
-
- @Override
- public String typeName() {
- return CONTENT_TYPE;
- }
-
- @Override
- public MappedFieldType clone() {
- return new LatLonPointFieldType(this);
- }
-
- @Override
- public IndexFieldData.Builder fielddataBuilder() {
- failIfNoDocValues();
- return new AbstractLatLonPointDVIndexFieldData.Builder();
- }
-
- @Override
- public Query termQuery(Object value, QueryShardContext context) {
- throw new QueryShardException(context, "Geo fields do not support exact searching, use dedicated geo queries instead: ["
- + name() + "]");
- }
-
- @Override
- public FieldStats.GeoPoint stats(IndexReader reader) throws IOException {
- String field = name();
- FieldInfo fi = org.apache.lucene.index.MultiFields.getMergedFieldInfos(reader).fieldInfo(name());
- if (fi == null) {
- return null;
- }
- final long size = PointValues.size(reader, field);
- if (size == 0) {
- return new FieldStats.GeoPoint(reader.maxDoc(), -1L, -1L, -1L, isSearchable(), isAggregatable());
- }
- final int docCount = PointValues.getDocCount(reader, field);
- byte[] min = PointValues.getMinPackedValue(reader, field);
- byte[] max = PointValues.getMaxPackedValue(reader, field);
- GeoPoint minPt = new GeoPoint(GeoEncodingUtils.decodeLatitude(min, 0), GeoEncodingUtils.decodeLongitude(min, Integer.BYTES));
- GeoPoint maxPt = new GeoPoint(GeoEncodingUtils.decodeLatitude(max, 0), GeoEncodingUtils.decodeLongitude(max, Integer.BYTES));
- return new FieldStats.GeoPoint(reader.maxDoc(), docCount, -1L, size, isSearchable(), isAggregatable(),
- minPt, maxPt);
- }
- }
-
- @Override
- protected void parse(ParseContext originalContext, GeoPoint point, String geoHash) throws IOException {
- // Geopoint fields, by default, will not be included in _all
- final ParseContext context = originalContext.setIncludeInAllDefault(false);
-
- if (ignoreMalformed.value() == false) {
- if (point.lat() > 90.0 || point.lat() < -90.0) {
- throw new IllegalArgumentException("illegal latitude value [" + point.lat() + "] for " + name());
- }
- if (point.lon() > 180.0 || point.lon() < -180) {
- throw new IllegalArgumentException("illegal longitude value [" + point.lon() + "] for " + name());
- }
- } else {
- GeoUtils.normalizePoint(point);
- }
- 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()));
- }
- // if the mapping contains multifields then use the geohash string
- if (multiFields.iterator().hasNext()) {
- multiFields.parse(this, context.createExternalValueContext(point.geohash()));
- }
- }
-}
diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java
index 1ca978b1b5..74e51afac3 100644
--- a/core/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java
+++ b/core/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java
@@ -35,7 +35,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper;
+import org.elasticsearch.index.mapper.GeoPointFieldMapper.GeoPointFieldType;
import org.elasticsearch.index.mapper.MappedFieldType;
import java.io.IOException;
@@ -321,7 +321,7 @@ public class GeoBoundingBoxQueryBuilder extends AbstractQueryBuilder<GeoBounding
throw new QueryShardException(context, "failed to find geo_point field [" + fieldName + "]");
}
}
- if (!(fieldType instanceof BaseGeoPointFieldMapper.GeoPointFieldType)) {
+ if (!(fieldType instanceof GeoPointFieldType)) {
throw new QueryShardException(context, "field [" + fieldName + "] is not a geo_point field");
}
diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryBuilder.java
index 169abb684e..c83686b028 100644
--- a/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryBuilder.java
+++ b/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryBuilder.java
@@ -34,7 +34,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper;
+import org.elasticsearch.index.mapper.GeoPointFieldMapper.GeoPointFieldType;
import org.elasticsearch.index.mapper.MappedFieldType;
import java.io.IOException;
@@ -235,7 +235,7 @@ public class GeoDistanceQueryBuilder extends AbstractQueryBuilder<GeoDistanceQue
}
}
- if (!(fieldType instanceof BaseGeoPointFieldMapper.GeoPointFieldType)) {
+ if (!(fieldType instanceof GeoPointFieldType)) {
throw new QueryShardException(shardContext, "field [" + fieldName + "] is not a geo_point field");
}
diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java
index 4678d35982..cc25ac4772 100644
--- a/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java
+++ b/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java
@@ -33,7 +33,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentParser.Token;
-import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper;
+import org.elasticsearch.index.mapper.GeoPointFieldMapper.GeoPointFieldType;
import org.elasticsearch.index.mapper.MappedFieldType;
import java.io.IOException;
@@ -159,7 +159,7 @@ public class GeoPolygonQueryBuilder extends AbstractQueryBuilder<GeoPolygonQuery
throw new QueryShardException(context, "failed to find geo_point field [" + fieldName + "]");
}
}
- if (!(fieldType instanceof BaseGeoPointFieldMapper.GeoPointFieldType)) {
+ if (!(fieldType instanceof GeoPointFieldType)) {
throw new QueryShardException(context, "field [" + fieldName + "] is not a geo_point field");
}
diff --git a/core/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionBuilder.java b/core/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionBuilder.java
index 6235f65488..77b67b89fc 100644
--- a/core/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionBuilder.java
+++ b/core/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionBuilder.java
@@ -43,7 +43,7 @@ import org.elasticsearch.index.fielddata.IndexNumericFieldData;
import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.NumericDoubleValues;
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
-import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper;
+import org.elasticsearch.index.mapper.GeoPointFieldMapper.GeoPointFieldType;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.NumberFieldMapper;
@@ -203,7 +203,7 @@ public abstract class DecayFunctionBuilder<DFB extends DecayFunctionBuilder<DFB>
parser.nextToken();
if (fieldType instanceof DateFieldMapper.DateFieldType) {
return parseDateVariable(parser, context, fieldType, mode);
- } else if (fieldType instanceof BaseGeoPointFieldMapper.GeoPointFieldType) {
+ } else if (fieldType instanceof GeoPointFieldType) {
return parseGeoVariable(parser, context, fieldType, mode);
} else if (fieldType instanceof NumberFieldMapper.NumberFieldType) {
return parseNumberVariable(parser, context, fieldType, mode);
diff --git a/core/src/main/java/org/elasticsearch/indices/IndicesModule.java b/core/src/main/java/org/elasticsearch/indices/IndicesModule.java
index c53b278e8a..e8a36c6006 100644
--- a/core/src/main/java/org/elasticsearch/indices/IndicesModule.java
+++ b/core/src/main/java/org/elasticsearch/indices/IndicesModule.java
@@ -36,7 +36,7 @@ import org.elasticsearch.index.mapper.IdFieldMapper;
import org.elasticsearch.index.mapper.IndexFieldMapper;
import org.elasticsearch.index.mapper.IpFieldMapper;
import org.elasticsearch.index.mapper.KeywordFieldMapper;
-import org.elasticsearch.index.mapper.LatLonPointFieldMapper;
+import org.elasticsearch.index.mapper.GeoPointFieldMapper;
import org.elasticsearch.index.mapper.Mapper;
import org.elasticsearch.index.mapper.MetadataFieldMapper;
import org.elasticsearch.index.mapper.NumberFieldMapper;
@@ -56,9 +56,6 @@ import org.elasticsearch.index.seqno.GlobalCheckpointSyncAction;
import org.elasticsearch.indices.cluster.IndicesClusterStateService;
import org.elasticsearch.indices.flush.SyncedFlushService;
import org.elasticsearch.indices.mapper.MapperRegistry;
-import org.elasticsearch.indices.recovery.PeerRecoverySourceService;
-import org.elasticsearch.indices.recovery.PeerRecoveryTargetService;
-import org.elasticsearch.indices.recovery.RecoverySettings;
import org.elasticsearch.indices.store.IndicesStore;
import org.elasticsearch.indices.store.TransportNodesListShardStoreMetaData;
import org.elasticsearch.plugins.MapperPlugin;
@@ -111,7 +108,7 @@ public class IndicesModule extends AbstractModule {
mappers.put(ObjectMapper.CONTENT_TYPE, new ObjectMapper.TypeParser());
mappers.put(ObjectMapper.NESTED_CONTENT_TYPE, new ObjectMapper.TypeParser());
mappers.put(CompletionFieldMapper.CONTENT_TYPE, new CompletionFieldMapper.TypeParser());
- mappers.put(LatLonPointFieldMapper.CONTENT_TYPE, new LatLonPointFieldMapper.TypeParser());
+ mappers.put(GeoPointFieldMapper.CONTENT_TYPE, new GeoPointFieldMapper.TypeParser());
if (ShapesAvailability.JTS_AVAILABLE && ShapesAvailability.SPATIAL4J_AVAILABLE) {
mappers.put(GeoShapeFieldMapper.CONTENT_TYPE, new GeoShapeFieldMapper.TypeParser());
}
diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java
index 9d5838b4b2..a689d21e70 100644
--- a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java
+++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java
@@ -29,7 +29,7 @@ import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentParser.Token;
-import org.elasticsearch.index.mapper.BaseGeoPointFieldMapper;
+import org.elasticsearch.index.mapper.GeoPointFieldMapper;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.ParseContext;
import org.elasticsearch.index.mapper.ParseContext.Document;
@@ -140,7 +140,7 @@ public class GeoContextMapping extends ContextMapping<GeoQueryContext> {
public Set<CharSequence> parseContext(ParseContext parseContext, XContentParser parser) throws IOException, ElasticsearchParseException {
if (fieldName != null) {
FieldMapper mapper = parseContext.docMapper().mappers().getMapper(fieldName);
- if (!(mapper instanceof BaseGeoPointFieldMapper)) {
+ if (!(mapper instanceof GeoPointFieldMapper)) {
throw new ElasticsearchParseException("referenced field must be mapped to geo_point");
}
}