I have created a template file with mapping for a parent-child relationship:
### Template file
{
"index_patterns" : [ "test-*" ],
"settings" : {
"index" : {
"number_of_shards" : "1",
"number_of_replicas" : "0"
}
},
"mappings": {
"doc": {
"properties": {
"family": {
"type": "join",
"relations": {
"customer": [ "file", "picture" ]
}
}
}
}
}
}
I have two config files, one for customers and one for files:
### Customer config
input {
stdin {
type => "customer"
}
}
filter {
csv {
columns => [ "customer_id", "first", "last", "contact_time" ]
separator => ","
remove_field => [message]
}
mutate {
add_field => { "family" => "customer" }
}
date {
match => [ "contact_time", "UNIX" ]
}
}
output {
elasticsearch {
hosts => ["elastic:9200"]
index => "test-%{+YYYY.MM}"
}
}
### File Config
input {
stdin {
type => "file"
}
}
filter {
csv {
columns => [ "customer_id", "filename", "contact_time" ]
separator => ","
remove_field => [message]
}
date {
match => [ "contact_time", "UNIX" ]
}
mutate {
add_field => {"[family][name]" => "file"}
add_field => {"[family][parent]" => "%{customer_id}"}
}
}
output {
elasticsearch {
hosts => ["elastic:9200"]
index => "test-%{+YYYY.MM}"
routing => "%{customer_id}"
}
}
Test CSV data for customers is:
- 5001,Joe,Bogel,1533339450
- 5002,Jim,Bogel,1533339476
- 5003,Jil,Bagel,1533339510
and for files:
- 5001,login.txt,1533339451
- 5001,logout.txt,1533339477
- 5001,session.txt,1533339511
- 5002,login.jpg,1533339452
- 5002,logout.jpg,1533339478
- 5002,session.jpg,1533339512
- 5003,login.gif,1533339453
- 5003,logout.gif,1533339479
- 5003,session.gif,1533339513
The data loads and is indexed without errors but the following query from Kibana does not return ANY documents:
{
"query": {
"has_child": {
"query": {
"term": {
"filename": "session.jpg"
}
},
"type": "file"
}
}
}
I would expect it to return the record for Jim Bogel with customer_id of 5002.
Here is the data for those records:
{
"_index" : "test-2018.08",
"_type" : "doc",
"_id" : "-aihAmUB5LAMSjzPZe2-",
"_score" : 1.0,
"_source" : {
"last" : "Bogel",
"contact_time" : "1533339476",
"@version" : "1",
"host" : "alpha",
"first" : "Jim",
"family" : "customer",
"customer_id" : "5002",
"type" : "customer",
"@timestamp" : "2018-08-03T23:37:56.000Z"
}
},
{
"_index" : "test-2018.08",
"_type" : "doc",
"_id" : "A6ihAmUB5LAMSjzP3O77",
"_score" : 1.0,
"_routing" : "5002",
"_source" : {
"contact_time" : "1533339510",
"@timestamp" : "2018-08-03T23:38:30.000Z",
"customer_id" : "5002",
"filename" : "session.jpg",
"family" : {
"parent" : "5002",
"name" : "file"
},
"host" : "alpha",
"@version" : "1",
"type" : "file"
}
}
This used to work well in 5.6.10 using the _parent field, but 6.3.2 join has not been friendly to me at all. Is there something obvious that I'm missing here? Any help would be greatly appreciated.