我想弄清楚如何做这个例子。比方说,我有3个文件结构如下:没有嵌套文档的文档数
{
"name": "test one",
"images": [
{
"id": 1
}
]
}
{
"name": "test two",
"images": []
}
{
"name": "test three",
"images": [
{
"id": 2
}
]
}
我想要么得到的文件计数与该images
场对象(在这种情况下是2),或(较不优选)文件数无对象在images
字段(在本例中为1)。这是为了聚合查询之一,万一这不明显。我试着约100种不同的聚合类型,包括这个
...
"withoutPhotos": {
"nested": {
"path": "images"
},
"aggs": {
"noPhoto": {
"missing": {
"field": "images.id"
}
}
}
}
此,
...
"withoutPhotos": {
"missing": {
"field": "images"
}
}
和他人的丰富性。有任何想法吗?