Open
Description
Elasticsearch Version
all
Installed Plugins
No response
Java Version
bundled
OS Version
all
Problem Description
We currently accept reverse_nested
aggregations even when the configuration is "unreversed." Check this out:
This sequence of aggs is invalid:
* nested (path = a)
* nested (path = a.b)
* reverse_nested (path = a)
* reverse_nested (path = a.b)
The second reverse_nested
presumes that it's in a unnesting from a child of a.b
but the first reverse_nested
has made the documents a parent of a.b
. This fails assertion errors while collecting. If assertions are enabled. And has done so at least back to 7.17. If assertion are not enabled it fails with a "read past EOF" error.
Steps to Reproduce
password="password"
http=http
curl -k -s -uelastic:$password -XDELETE ${http}://localhost:9200/test
curl -k -s -uelastic:$password -XPUT -HContent-Type:application/json ${http}://localhost:9200/test -d'{
"mappings": {
"dynamic": "false",
"properties": {
"n1": {
"type": "nested",
"properties": {
"n2": {
"type": "nested"
}
}
}
}
}
}'
curl -k -s -uelastic:$password -XPOST -HContent-Type:application/json ${http}://localhost:9200/test/_doc?pretty -d'{
"n1": {
"n2": {
"rating": 1
}
}
}'
curl -k -s -uelastic:$password -XGET ${http}://localhost:9200/_refresh
curl -k -s -uelastic:$password -XPOST -HContent-Type:application/json ${http}://localhost:9200/test/_search?pretty -d'
{
"size": 0,
"aggregations": {
"n1": {
"nested": { "path": "n1" },
"aggregations": {
"n2": {
"nested": { "path": "n1.n2" },
"aggregations": {
"r1": {
"reverse_nested": { "path": "n1" },
"aggregations": {
"r2": {
"reverse_nested": { "path": "n1.n2" }
}
}
}
}
}
}
}
}
}'
Logs (if relevant)
No response