【发布时间】:2014-12-23 13:46:18
【问题描述】:
我正试图弄清楚如何做类似这个例子的事情。假设我有 3 个具有以下结构的文档:
{
"name": "test one",
"images": [
{
"id": 1
}
]
}
{
"name": "test two",
"images": []
}
{
"name": "test three",
"images": [
{
"id": 2
}
]
}
我想获取 images 字段中的文档 WITH 对象的计数(在本例中为 2),或者(不太理想)文档计数 images 字段中没有 对象(在本例中为 1)。这是针对聚合查询之一,以防不明显。我已经尝试了大约 100 种不同的聚合类型,包括这个
...
"withoutPhotos": {
"nested": {
"path": "images"
},
"aggs": {
"noPhoto": {
"missing": {
"field": "images.id"
}
}
}
}
这个,
...
"withoutPhotos": {
"missing": {
"field": "images"
}
}
还有很多其他的。有什么想法吗?
【问题讨论】:
标签: elasticsearch facet