Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/87051.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 87051
summary: Guard for adding null value tags to vector tiles
area: Geo
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ private void createIndexAndPutGeometry(String indexName, Geometry geometry, Stri
},
"name": {
"type": "keyword"
},
"ignore_value": {
"type": "double",
"ignore_malformed" : true
}
}
}""");
Expand All @@ -132,7 +136,7 @@ private void createIndexAndPutGeometry(String indexName, Geometry geometry, Stri
final Request putRequest = new Request(HttpPost.METHOD_NAME, indexName + "/_doc/" + id);
putRequest.setJsonEntity("""
{
"location": "%s", "name": "geometry", "value1": %s, "value2": %s, "nullField" : null
"location": "%s", "name": "geometry", "value1": %s, "value2": %s, "nullField" : null, "ignore_value" : ""
}""".formatted(WellKnownText.toWKT(geometry), 1, 2));
response = client().performRequest(putRequest);
assertThat(response.getStatusLine().getStatusCode(), Matchers.equalTo(HttpStatus.SC_CREATED));
Expand Down Expand Up @@ -787,6 +791,16 @@ public void testWithNullFields() throws Exception {
assertLayer(tile, META_LAYER, 4096, 1, 13);
}

public void testWithIgnoreMalformedValueFields() throws Exception {
final Request mvtRequest = new Request(getHttpMethod(), INDEX_POLYGON + "/_mvt/location/" + z + "/" + x + "/" + y);
mvtRequest.setJsonEntity("{\"fields\": [ \"ignore_value\"] }");
final VectorTile.Tile tile = execute(mvtRequest);
assertThat(tile.getLayersCount(), Matchers.equalTo(3));
assertLayer(tile, HITS_LAYER, 4096, 1, 2);
assertLayer(tile, AGGS_LAYER, 4096, 256 * 256, 2);
assertLayer(tile, META_LAYER, 4096, 1, 13);
}

public void testWithFieldsWildCard() throws Exception {
final Request mvtRequest = new Request(getHttpMethod(), INDEX_POLYGON + "/_mvt/location/" + z + "/" + x + "/" + y);
mvtRequest.setJsonEntity("{\"fields\": [\"*\"] }");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public static void addToXContentToFeature(VectorTile.Tile.Feature.Builder featur
* Adds the provided key / value pair into the feature as tags.
*/
public static void addPropertyToFeature(VectorTile.Tile.Feature.Builder feature, MvtLayerProps layerProps, String key, Object value) {
if (value == null) {
// guard for null values
return;
}
feature.addTags(layerProps.addKey(key));
feature.addTags(layerProps.addValue(value));
}
Expand Down