This commit is contained in:
parent
7d9c064218
commit
03d717dc32
|
@ -104,6 +104,17 @@ public class GeoShapeFieldMapper extends AbstractGeometryFieldMapper<Geometry, G
|
|||
multiFields, copyTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doMerge(Mapper mergeWith) {
|
||||
if (mergeWith instanceof LegacyGeoShapeFieldMapper) {
|
||||
LegacyGeoShapeFieldMapper legacy = (LegacyGeoShapeFieldMapper) mergeWith;
|
||||
throw new IllegalArgumentException("[" + fieldType().name() + "] with field mapper [" + fieldType().typeName() + "] " +
|
||||
"using [BKD] strategy cannot be merged with " + "[" + legacy.fieldType().typeName() + "] with [" +
|
||||
legacy.fieldType().strategy() + "] strategy");
|
||||
}
|
||||
super.doMerge(mergeWith);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeoShapeFieldType fieldType() {
|
||||
return (GeoShapeFieldType) super.fieldType();
|
||||
|
|
|
@ -536,6 +536,17 @@ public class LegacyGeoShapeFieldMapper extends AbstractGeometryFieldMapper<Shape
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doMerge(Mapper mergeWith) {
|
||||
if (mergeWith instanceof GeoShapeFieldMapper) {
|
||||
GeoShapeFieldMapper fieldMapper = (GeoShapeFieldMapper) mergeWith;
|
||||
throw new IllegalArgumentException("[" + fieldType().name() + "] with field mapper [" + fieldType().typeName() + "] " +
|
||||
"using [" + fieldType().strategy() + "] strategy cannot be merged with " + "[" + fieldMapper.typeName() +
|
||||
"] with [BKD] strategy");
|
||||
}
|
||||
super.doMerge(mergeWith);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String contentType() {
|
||||
return CONTENT_TYPE;
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.test.ESIntegTestCase;
|
|||
import static org.elasticsearch.index.query.QueryBuilders.geoShapeQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
|
||||
|
@ -123,6 +124,27 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
|
|||
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
||||
}
|
||||
|
||||
public void testMappingUpdate() throws Exception {
|
||||
// create index
|
||||
assertAcked(client().admin().indices().prepareCreate("test")
|
||||
.addMapping("geometry", "shape", "type=geo_shape").get());
|
||||
ensureGreen();
|
||||
|
||||
String update ="{\n" +
|
||||
" \"properties\": {\n" +
|
||||
" \"shape\": {\n" +
|
||||
" \"type\": \"geo_shape\",\n" +
|
||||
" \"strategy\": \"recursive\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> client().admin().indices()
|
||||
.preparePutMapping("test").setType("geometry")
|
||||
.setSource(update, XContentType.JSON).get());
|
||||
assertThat(e.getMessage(), containsString("using [BKD] strategy cannot be merged with"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the indexed shape routing can be provided if it is required
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue