Hi,
Let's say I have a nested type "points":
"points": [{x: 1, y: 1}, {x:5, y:3},...]
Why is it in that the following query works when I use the term points:
GET /mockindex/_search?size=5
{
"query" : {
"nested" : {
"path" : "points",
"query": {
"exists" : { "field" : "points" }
}
}
}
}
but when I do an aggregation query, using the term "points" doesn't work and I have to do points.x or points.y.
For example this query works:
{
"aggregations" : {
"nested_layer" : {
"nested": {
"path": "points"
},
"aggregations" : {
"result" : {
"value_count": {"field": "points.x"}
}
}
}
}
}
and it will return the number of points I have (another way to think of it is that it will return the number of documents I have once Elasticsearch splits each nested type into its own document). However, if I replace points.x with just points, the query doesn't work anymore.
My question is this: if elasticsearch internally represents nested type "points" as "points.x" and "points.y" then how was the first query able to understand when I said "field": "points"? My second question is why am I not able to use "field": "points" in the aggregation query if I was able to use it in the first query? And lastly, is there a way I can write a value_count query so that it will return the number of documents that contain the field "points" and not the number internally represented documents where "points" are all separated out?