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

Filter by extension

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/83310.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 83310
summary: "TSDB: routingPath object type check improvement"
area: TSDB
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ ecs style:
---
top level dim object:
- skip:
version: " - 8.0.99"
reason: introduced in 8.1.0
version: " - 8.1.99"
reason: routing_path object type check improve in 8.2.0

- do:
indices.create:
Expand All @@ -66,7 +66,7 @@ top level dim object:
settings:
index:
mode: time_series
routing_path: [dim.*]
routing_path: [dim*]
time_series:
start_time: 2021-04-28T00:00:00Z
end_time: 2021-04-29T00:00:00Z
Expand Down Expand Up @@ -111,6 +111,39 @@ top level dim object:
type: double
time_series_metric: gauge

---
match object but no match object children:
- skip:
version: " - 8.1.99"
reason: routing_path object type check improve in 8.2.0

- do:
catch: '/All fields that match routing_path must be keywords with \[time_series_dimension: true\] and without the \[script\] parameter. \[dim\] was \[object\]./'
indices.create:
index: tsdb_index
body:
settings:
index:
mode: time_series
routing_path: [dim]
time_series:
start_time: 2021-04-28T00:00:00Z
end_time: 2021-04-29T00:00:00Z
number_of_replicas: 0
number_of_shards: 2
mappings:
properties:
"@timestamp":
type: date
dim:
properties:
metricset:
type: keyword
time_series_dimension: true
uid:
type: keyword
time_series_dimension: true

---
non keyword matches routing_path:
- skip:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ public void validate(IndexSettings settings, boolean checkLimits) {
mappingLookup.getFieldType(match).validateMatchedRoutingPath();
}
for (String objectName : mappingLookup.objectMappers().keySet()) {
if (Regex.simpleMatch(path, objectName)) {
// if path match objectName, and path is not end with '*' .
// it means the object' children can't match the path.
if (Regex.simpleMatch(path, objectName) && false == path.endsWith("*")) {
throw new IllegalArgumentException(
"All fields that match routing_path must be keywords with [time_series_dimension: true] "
+ "and without the [script] parameter. ["
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,22 @@ public void testValidateAliasWithSearchRouting() {
assertThat(e.getMessage(), equalTo("routing is forbidden on CRUD operations that target indices in [index.mode=time_series]"));
}

public void testRoutingPathMatchesObject() {
Settings s = getSettings(randomBoolean() ? "dim.o" : "dim.*");
public void testRoutingPathMatchesObject() throws IOException {
Settings s = getSettings("dim.o*");
createMapperService(s, mapping(b -> {
b.startObject("dim").startObject("properties");
{
b.startObject("o").startObject("properties");
b.startObject("inner_dim").field("type", "keyword").field("time_series_dimension", true).endObject();
b.endObject().endObject();
}
b.startObject("dim").field("type", "keyword").field("time_series_dimension", true).endObject();
b.endObject().endObject();
}));
}

public void testRoutingPathMatchesObjectError() {
Settings s = getSettings("dim.o");
Exception e = expectThrows(IllegalArgumentException.class, () -> createMapperService(s, mapping(b -> {
b.startObject("dim").startObject("properties");
{
Expand Down