Hello,
- we have an index transform job, created as below (shortened for the sake of brevity)
PUT /_plugins/_transform/my_test_transform
{
"transform": {
"enabled": true,
"schedule": {
"interval": {
"period": 1,
"unit": "Minutes",
"start_time": 1602100553
}
},
"description": "create index my_test_transform",
"source_index": "my_test_src_index",
"target_index": "my_test_target_index",
"page_size": 1,
"groups": [
{
"terms": {
"source_field": "message_header.global_tenant_id",
"target_field": "message_header.global_tenant_id"
}
}
],
"aggregations": {
"usage_data.data_read_kb": {
"sum": {
"field": "usage_data.data_read_kb"
}
},
"usage_data": {
"scripted_metric": {
"init_script": "state.docs = [];",
"map_script": """
Map span = [
'occurred_message_timestamp_utc_ms':doc['occurred_message_timestamp_utc_ms'].value
];
state.docs.add(span);
""",
"combine_script": "return state.docs;",
"reduce_script": """
def ret = new HashMap();
ret['device_friendly_name'] = 'test123';
return ret;
"""
}
}
}
}
}
- Both source and target indexes contain multi tenant documents, so we use document field "message_header.global_tenant_id" as routing value.
The source and target indexes both have an index template with mapping that specifies:
"_routing": {
"required": true
}
- when running the transform job it fails with exception "RoutingMissingException"
- to verify this is the root cause, we removed the "routing = true" from target index template, and now the transform job completes successfully!!
- However we would like to keep "routing = true" in target index, so that tenant documents in target index are located in same shard (better for search performance)
How do we accomplish this?
Thanks,
Assaf