Hi All,
i couldn't figure out how to define a join datatype relationship following the documentation on join datatype
Mapping:
curl -XPUT localhost:9200/bookings -H 'Content-Type: application/json' -d '
{
"mappings": {
"doc": {
"properties": {
"join_field": {
"type": "join",
"relations": {
"booking": "segment"
}
},
"booking": {
"type": "nested",
"properties": {
"booking_id": {
"type": "integer"
}
}
},
"segment": {
"type": "nested",
"properties": {
"service": {
"type": "keyword"
}
}
}
}
}
}
}
Parent:
curl -XPUT 'localhost:9200/bookings/doc/1?routing=1&refresh&pretty' -H 'Content-Type: application/json' -d'
{
"booking": {
"booking_id": 1,
"join_field": {
"name": "booking"
}
}
}
'
Child:
curl -XPUT 'localhost:9200/bookings/doc/2?routing=1&refresh&pretty' -H 'Content-Type: application/json' -d'
{
"segment": {
"service": "asdasd",
"join_field": {
"name": "segment",
"parent": 1
}
}
}
'
Query:
curl -XGET 'localhost:9200/bookings/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"has_child" : {
"type" : "segment",
"query" : {
"match_all": {}
}
}
}
}'
Result:
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
Could you tell me what am i doing wrong here?