|
@@ -15,6 +15,7 @@ import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.action.ActionListener;
|
|
|
import org.elasticsearch.action.get.GetRequest;
|
|
|
import org.elasticsearch.client.Client;
|
|
|
+import org.elasticsearch.common.logging.DeprecationLogger;
|
|
|
import org.elasticsearch.common.xcontent.ParseField;
|
|
|
import org.elasticsearch.common.ParsingException;
|
|
|
import org.elasticsearch.common.geo.GeoJson;
|
|
@@ -29,6 +30,7 @@ import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
|
|
import org.elasticsearch.common.xcontent.XContentParser;
|
|
|
+import org.elasticsearch.core.RestApiVersion;
|
|
|
import org.elasticsearch.geometry.Geometry;
|
|
|
import org.elasticsearch.index.mapper.MappedFieldType;
|
|
|
import org.elasticsearch.index.mapper.MapperService;
|
|
@@ -41,6 +43,9 @@ import java.util.function.Supplier;
|
|
|
* Base {@link QueryBuilder} that builds a Geometry Query
|
|
|
*/
|
|
|
public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>> extends AbstractQueryBuilder<QB> {
|
|
|
+ static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Types are deprecated in [geo_shape] queries. " +
|
|
|
+ "The type should no longer be specified in the [indexed_shape] section.";
|
|
|
+ private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(AbstractGeometryQueryBuilder.class);
|
|
|
|
|
|
public static final String DEFAULT_SHAPE_INDEX_NAME = "shapes";
|
|
|
public static final String DEFAULT_SHAPE_FIELD_NAME = "shape";
|
|
@@ -53,6 +58,7 @@ public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQu
|
|
|
protected static final ParseField RELATION_FIELD = new ParseField("relation");
|
|
|
protected static final ParseField INDEXED_SHAPE_FIELD = new ParseField("indexed_shape");
|
|
|
protected static final ParseField SHAPE_ID_FIELD = new ParseField("id");
|
|
|
+ protected static final ParseField SHAPE_TYPE_FIELD = new ParseField("type");
|
|
|
protected static final ParseField SHAPE_INDEX_FIELD = new ParseField("index");
|
|
|
protected static final ParseField SHAPE_PATH_FIELD = new ParseField("path");
|
|
|
protected static final ParseField SHAPE_ROUTING_FIELD = new ParseField("routing");
|
|
@@ -408,6 +414,9 @@ public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQu
|
|
|
} else {
|
|
|
builder.startObject(INDEXED_SHAPE_FIELD.getPreferredName())
|
|
|
.field(SHAPE_ID_FIELD.getPreferredName(), indexedShapeId);
|
|
|
+ if (builder.getRestApiVersion() == RestApiVersion.V_7) {
|
|
|
+ builder.field(SHAPE_TYPE_FIELD.getPreferredName(), MapperService.SINGLE_MAPPING_NAME);
|
|
|
+ }
|
|
|
if (indexedShapeIndex != null) {
|
|
|
builder.field(SHAPE_INDEX_FIELD.getPreferredName(), indexedShapeIndex);
|
|
|
}
|
|
@@ -521,6 +530,9 @@ public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQu
|
|
|
} else if (token.isValue()) {
|
|
|
if (SHAPE_ID_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
|
|
|
params.id = parser.text();
|
|
|
+ } else if (parser.getRestApiVersion() == RestApiVersion.V_7 &&
|
|
|
+ SHAPE_TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
|
|
|
+ deprecationLogger.compatibleApiWarning("geo_share_query_with_types", TYPES_DEPRECATION_MESSAGE);
|
|
|
} else if (SHAPE_INDEX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
|
|
|
params.index = parser.text();
|
|
|
} else if (SHAPE_PATH_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
|