我有这些文件:
{"title": "aa","cast": ["a","b","c","a"]}
{"title": "bb","cast": ["a","b","c","b"]}
{"title": "cc","cast": ["a","b","c","c"]}
我使用刻面得到结果。
facets": {
"cast_result": {
"_type": "terms",
"missing": 0,
"total": 9,
"other": 0,
"terms": [
{
"term": "c",
"count": 3
},
{
"term": "b",
"count": 3
},
{
"term": "a",
"count": 3
}
]
}
}
}
但是我希望结果“a”的数量为四,因为在实际文档中“a”的频率为四。“b”和“c”也与“a”相似。
最佳答案
但是我发现一个问题,当分片的数量大于2时,答案是错误的,因此它必须小于2。与副本数无关。
关于arrays - 如何在Elasticsearch中按值数组查询/过滤精确计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28848809/