我有一个存储在 ElasticSearch 中的文档,如下所示。
_来源:
{
"firstname": "John",
"lastname": "Smith",
"medals":[
{
"bucket": 100,
"count": 1
},
{
"bucket": 150,
"count": 2
}
]
}
我可以使用访问文档内的字符串类型值doc.firstname
用于脚本化指标聚合http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html.
但我无法使用获取字段值doc.medals[0].bucket.
您能帮助我并让我知道如何访问嵌套字段内的值吗?
使用 _source 作为嵌套属性。
Doc 保存加载到内存中的字段。嵌套文档可能无法加载,应使用 _source 进行访问。
例如:
GET index/type
{
"aggs": {
"NAME": {
"scripted_metric": {
"init_script": "_agg['collection']=[]",
"map_script": "_agg['tr'].add(_source.propertry1.prop);",
"combine_script": "return _agg",
"reduce_script": "return _aggs"
}
}
},
"size": 0
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)