Hi,
Nowadays, I am creating two types inside of same Index. The firts type is the parent type and it is child from another type too. His mapping is:
{
"company": {
"mappings": {
"lic_server": {
"_parent": {
"type": "customer"
},
"_routing": {
"required": true
},
"properties": {
"id": {
"type": "string",
"index": "not_analyzed"
},
"name": {
"type": "string",
"index": "not_analyzed"
},
"updated_at": {
"type": "date",
"format": "dateOptionalTime"
}
}
}
}
}
}
And we have instances of this type inside of the index for example:
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 4.4812403,
"hits": [
{
"_index": "company",
"_type": "lic__server",
"_id": "oid:asset:3",
"_score": 4.4812403,
"_source": {
"updated_at": "2015-07-29T10:48:12.696465",
"name": "lic.server ",
"id": "oid:3"
}
}
]
}
}
And its child would be the next mapping:
{
"company": {
"mappings": {
"event_lic_server": {
"_parent": {
"type": "lic_server"
},
"_routing": {
"required": true
},
"properties": {
"application": {
"type": "string",
"index": "not_analyzed"
},
"timestamp": {
"type": "date",
"format": "dateOptionalTime"
},
"updated_at": {
"type": "date",
"format": "dateOptionalTime"
},
"value": {
"type": "integer"
}
}
}
}
}
}
And would be instances that will be child from parent "id": "oid:3". For example:
{
"took": 7,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 6241,
"max_score": 3.6967838,
"hits": [
{
"_index": "company",
"_type": "event_lic_server",
"_id": "AU7ZLHEABnc3vxnAccdb",
"_score": 3.6967838,
"fields": {
"_parent": "oid:3"
}
},
{
"_index": "company",
"_type": "event_lic_server",
"_id": "AU7ZLHEDBnc3vxnAccdc",
"_score": 3.6967838,
"fields": {
"_parent": "oid:3"
}
},
{
"_index": "company",
"_type": "event_lic_server",
"_id": "AU7ZLHEGBnc3vxnAccdd",
"_score": 3.6967838,
"fields": {
"_parent": "oid:3"
}
} ......
But my problem is when I ask to child by parent Id using the has_parent query that doesn´t works correctly. For example:
GET company/event_lic_server/_search
{
"query": {
"has_parent": {
"parent_type": "lic_server",
"query": {
"term": {
"id": {
"value": "oid:3"
}
}
}
}
}
}
And the result is:
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
Please, could somebody tell me where is the problemm or give me any idea about this. Because I am not be able to do it.
The first relation works correcty:
Grandparent --> Child/Parent works
But:
Child/Parent --> Child/GrandChild doesn´t work.
I have more than one GrandChild.
Thanks in advance and sorry by the inconvenience.