Given是一个Elasticsearch(版本7.4.0)查询,在嵌套字段上聚合。我查看了所有文档,但找不到任何可以解释将使用的等效Java函数的内容。
架构如下:
"mappings": {
"_doc": {
"dynamic": "false",
"properties": {
"id": {
"type": "text"
},
"name": {
"type": "text",
"fielddata": True
},
"amenities": {
"type": "nested",
"fielddata": True,
"properties": {
"id": {
"type": "long"
},
"name": {
"type": "text"
}
}
}}
对此的Elasticsearch查询如下:
{
"aggs": {
"amenities": {
"nested": {
"path": "amenities"
},
"aggs": {
"amn": {
"terms": {
"field": "amenities.name.raw"
},
"aggs": {
"id": {"top_hits": {"size": 1, "_source": {"include": ["amenities.id"]}}}
}
}
}
}
}
}
与Java(JDK-1.8)中的上述查询等效吗?