- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有elasticsearch群集-版本1.3.0。该集群的索引文档未启用_source,因此在检索匹配项时,通常会基于请求中的“fields”参数来获取。
现在,我正在为重复的分组功能实现top_hits
聚合。我想获取top_hits
结果中的字段,但由于我的映射默认未启用_source
,所以我现在无法执行此操作。您能否建议我在不更改现有映射的情况下实现这一目标的选项/解决方法?
我在top-hits aggregation doc中找不到它。任何帮助对此表示赞赏。
谢谢!
最佳答案
"aggs": {
"sample": {
"top_hits": {
"size": 1,
"script_fields": {
"field1": {
"script": "doc['field1']"
},
"field2": {
"script": "doc['field2']"
}
...
}
}
}
}
field1
或
field2
,则需要一个子字段,该子字段应保留该字段的
not_analyzed
版本。为什么?因为,如果以任何方式分析正常字段,
doc['field']
调用都将返回分析的术语,而不是被索引的初始内容。
"mappings": {
"test": {
"_source": {
"enabled": false
},
"properties": {
"field1": {
"type": "string",
"fields": {
"notAnalyzed": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
"aggs": {
"sample": {
"top_hits": {
"size": 1,
"script_fields": {
"field1": {
"script": "doc['field1.notAnalyzed']"
}
}
}
}
}
关于elasticsearch - 如何在top_hits聚合中获取字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32754266/
我正在尝试获取上次事件为“连接”的用户列表。理想情况下,我希望将其作为 Kibana 中的指标可视化或数据表,分别显示最后连接的用户数量和用户列表。但是,我已经放弃了在 Kibana 中执行此操作的能
这是我的带有嵌套价格数组的文档/映射: { "name": "Foobar", "type": 1, "prices": [ {
我正在使用 Elasticsearch GeoHash 网格聚合进行 map 聚类。查询平均返回 100-200 个桶。每个桶都使用 top_hits 聚合,我用它为每个聚合集群返回 3 个文档。 问
我想按地址分组,然后按日期获取最新地址,然后按状态过滤此结果。 ex {address: 'A', date: '10-10-1991', status: 'sold'} {address:
以下是示例文档: { "player": "Jim", "score" : 5 "timestamp": 1459492890000 } { "player": "Ji
我正在运行一个大号的 elasticsearch 过滤器。 (约 1000 万次点击)结果。我的 from+size 最大值是默认值(10,000 次匹配)。我想基于一个字段进行聚合,并返回所有桶中过
我是一名优秀的程序员,十分优秀!