作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要使用elasticsearch
查找不同字段ID的数量
我的数据格式是
{
"_index": "outboxprov1",
"_type": "user",
"_id": "16bcd4dc080f4c789018dd97f76741ef",
"_score": 1,
"_source": {
"first_name": "jinu",
"team_id": "500"
}
},
{
"_index": "outboxprov1",
"_type": "user",
"_id": "9ed8afe738aa63c28b66994cef1f83c6",
"_score": 1,
"_source": {
"first_name": "lal",
"team_id": "500"
}
},
{
"_index": "outboxprov1",
"_type": "user",
"_id": "1d238cd2f8c06790fc20859a16e3183b",
"_score": 1,
"_source": {
"first_name": "author1",
"team_id": "500"
}
},
{
"_index": "outboxprov1",
"_type": "user",
"_id": "616ee1c00a02564f71bb6c3067054d55",
"_score": 1,
"_source": {
"first_name": "kannan",
"team_id": "400"
}
},
{
"_index": "outboxprov1",
"_type": "user",
"_id": "d48132bfaed792f3c32d12e310d41c87",
"_score": 1,
"_source": {
"first_name": "author3",
"team_id": "400"
}
},
{
"_index": "outboxprov1",
"_type": "user",
"_id": "1a9d05586a8dc3f29b4c8147997391f9",
"_score": 1,
"_source": {
"first_name": "dibish",
"team_id": "100"
}
}
]
}
team_id
:
500, 400, 100
。在这种情况下,我希望得到3。我尝试了基数聚合:
{
"size": 0,
"query" : {
"match_all" : { }
},
"aggs" : {
"team_id_count" : {
"cardinality" : {
"field" : "team_id"
}
}
}
}
elasticsearch
文档指出基数是实验性功能,将来可能会发生变化。
最佳答案
您可以使用terms aggregation
像这样:
curl -XPOST http://localhost:9200/outboxprov1/user/_search -d '
{
"size": 0,
"query" : {
"match_all" : { }
},
"aggs" : {
"team_id_count" : {
"terms" : {
"field" : "team_id"
}
}
}
}'
关于elasticsearch - Elasticsearch获取不同行的计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24669901/
在我的 android 应用程序中,我想在同一行中实现 2 个文本字段。如果文本太长可以转到下一行。所以我使用了更精简的水平布局并添加了 2 个文本字段。 [例如:TextView1、TextV
由于node使用了javascript,它可以充当webrtc peer吗? 然后我可以将它编码为 VP8 流并广播给所有其他对等方吗? 最佳答案 WebRTC 是一个浏览器 API 而不是 Java
我是一名优秀的程序员,十分优秀!