15
15
import org .elasticsearch .action .ActionListener ;
16
16
import org .elasticsearch .action .get .GetRequest ;
17
17
import org .elasticsearch .client .Client ;
18
+ import org .elasticsearch .common .logging .DeprecationLogger ;
18
19
import org .elasticsearch .common .xcontent .ParseField ;
19
20
import org .elasticsearch .common .ParsingException ;
20
21
import org .elasticsearch .common .geo .GeoJson ;
29
30
import org .elasticsearch .common .xcontent .XContentBuilder ;
30
31
import org .elasticsearch .common .xcontent .XContentHelper ;
31
32
import org .elasticsearch .common .xcontent .XContentParser ;
33
+ import org .elasticsearch .core .RestApiVersion ;
32
34
import org .elasticsearch .geometry .Geometry ;
33
35
import org .elasticsearch .index .mapper .MappedFieldType ;
34
36
import org .elasticsearch .index .mapper .MapperService ;
41
43
* Base {@link QueryBuilder} that builds a Geometry Query
42
44
*/
43
45
public abstract class AbstractGeometryQueryBuilder <QB extends AbstractGeometryQueryBuilder <QB >> extends AbstractQueryBuilder <QB > {
46
+ static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Types are deprecated in [geo_shape] queries. " +
47
+ "The type should no longer be specified in the [indexed_shape] section." ;
48
+ private static final DeprecationLogger deprecationLogger = DeprecationLogger .getLogger (AbstractGeometryQueryBuilder .class );
44
49
45
50
public static final String DEFAULT_SHAPE_INDEX_NAME = "shapes" ;
46
51
public static final String DEFAULT_SHAPE_FIELD_NAME = "shape" ;
@@ -53,6 +58,7 @@ public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQu
53
58
protected static final ParseField RELATION_FIELD = new ParseField ("relation" );
54
59
protected static final ParseField INDEXED_SHAPE_FIELD = new ParseField ("indexed_shape" );
55
60
protected static final ParseField SHAPE_ID_FIELD = new ParseField ("id" );
61
+ protected static final ParseField SHAPE_TYPE_FIELD = new ParseField ("type" );
56
62
protected static final ParseField SHAPE_INDEX_FIELD = new ParseField ("index" );
57
63
protected static final ParseField SHAPE_PATH_FIELD = new ParseField ("path" );
58
64
protected static final ParseField SHAPE_ROUTING_FIELD = new ParseField ("routing" );
@@ -408,6 +414,9 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
408
414
} else {
409
415
builder .startObject (INDEXED_SHAPE_FIELD .getPreferredName ())
410
416
.field (SHAPE_ID_FIELD .getPreferredName (), indexedShapeId );
417
+ if (builder .getRestApiVersion () == RestApiVersion .V_7 ) {
418
+ builder .field (SHAPE_TYPE_FIELD .getPreferredName (), MapperService .SINGLE_MAPPING_NAME );
419
+ }
411
420
if (indexedShapeIndex != null ) {
412
421
builder .field (SHAPE_INDEX_FIELD .getPreferredName (), indexedShapeIndex );
413
422
}
@@ -521,6 +530,9 @@ public static ParsedGeometryQueryParams parsedParamsFromXContent(XContentParser
521
530
} else if (token .isValue ()) {
522
531
if (SHAPE_ID_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
523
532
params .id = parser .text ();
533
+ } else if (parser .getRestApiVersion () == RestApiVersion .V_7 &&
534
+ SHAPE_TYPE_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
535
+ deprecationLogger .compatibleApiWarning ("geo_share_query_with_types" , TYPES_DEPRECATION_MESSAGE );
524
536
} else if (SHAPE_INDEX_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
525
537
params .index = parser .text ();
526
538
} else if (SHAPE_PATH_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
0 commit comments