Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -54,10 +54,10 @@ ecs style:
time_series_metric: gauge

---
top level dim object:
top level wildcard 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

---
exact match object type:
- 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 @@ -9,7 +9,6 @@
package org.elasticsearch.index.mapper;

import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.index.IndexSettings;

import java.util.List;
Expand Down Expand Up @@ -104,7 +103,8 @@ public void validate(IndexSettings settings, boolean checkLimits) {
mappingLookup.getFieldType(match).validateMatchedRoutingPath();
}
for (String objectName : mappingLookup.objectMappers().keySet()) {
if (Regex.simpleMatch(path, objectName)) {
// object type is not allowed in the routing paths
if (path.equals(objectName)) {
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 @@ -144,8 +144,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 testRoutingPathEqualsObjectNameError() {
Settings s = getSettings("dim.o");
Exception e = expectThrows(IllegalArgumentException.class, () -> createMapperService(s, mapping(b -> {
b.startObject("dim").startObject("properties");
{
Expand Down