I have a weird issue with the has_parent filter.
I have following 3 documents in grandparent-parent-child relationship (for
all documents routing is set to doc1 which is the root document).
In additional to the parent setting I also define an object type (doc1) in
doc2 that contains the id and the name of the doc1 (denormalize the
document)
"doc1": {
"properties": {
"name": {"type":"string"},
}
}
"doc2": {
"_parent": {
"type": "doc1"
},
"properties": {
"name":{"type":"string"},
"doc1": {
"type":"object",
"properties":{
"id":{"type":"integer"},
"name":{"type":"string"}
}
},
"field1": {
"type": "object",
"properties":{
"id":{"type":"integer"},
"name":{"type":"string"}
}
}
"doc3": {
"_parent": {
"type": "doc2"
},
}
I want to retrieve all doc3 documents that are grandchildren of a specific
grandparent doc1. The easiert way would be to combine the has_parent filter
- and the embeded doc1 field in the doc2 document to do it:
_search against doc3
{
"query" : {
"constant_score" : {
"filter" : {
"has_parent" : {
"filter" : {
"term" : {
"doc1.id" : "1"
}
},
"parent_type" : "doc2"
}
}
}
}
}
Result: 0 hits
This queries returns nothing (I also tried to use the name field of the
embedded doc1 field but this leads to the same result).
If I use the same query on a different object type field (u..e field1) in
doc2 I get some hits.
If I use two has_parent filters it also works fine.
_search against doc3
{
"query" : {
"constant_score" : {
"filter" : {
"has_parent" : {
"filter" : {
"has_parent": {
"filter": {
"term" : {
"_id" : "1"
}
},
"parent_type":"doc1"
}
},
"parent_type" : "doc2"
}
}
}
}
}
Could it be that there is some collision between the field name (doc1) and
the parent_type/parent (doc1) ?
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.