如何计算 Elasticsearch 中嵌套字段中的对象数? 示例映射:
"base_keywords": {
"type": "nested",
"properties": {
"base_key": {
"type": "text"
},
"category": {
"type": "text"
},
"created_at": {
"type": "date"
},
"date": {
"type": "date"
},
"rank": {
"type": "integer"
}
}
}
我想计算嵌套字段“base_keywords”中的对象数。
最佳答案
您需要使用内联脚本来执行此操作。这对我有用:(使用 ES 6.x):
GET your-indices/_search
{
"aggs": {
"whatever": {
"sum": {
"script": {
"inline": "params._source.base_keywords.size()"
}
}
}
}
}
关于elasticsearch - 如何计算 Elasticsearch 中嵌套字段中的对象数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48881017/