我在尝试找出每个标签的文档数量的聚合方式是如何工作时遇到了一些问题。
我的映射如下:
"properties" => array(
"name" => array(
"type" => "string"
),
"location" => array(
"type" => "geo_point"
),
"city" => array(
"type" => "string",
),
"tags" => array(
"type" => "integer"
))
tags
包含一个整数数组。我试过了:
"aggs": {
"tags_count": {
"terms": {
"field": "tags"
}
}
我认为因为它是一个标签数组,所以它不会单独使用每个标记并查看结果查询并尝试聚合结果中存在的那些标记。
有些点击会非常感激!
搜索结果:
"hits":
{
"total": 345,
"max_score": 1,
"hits":
[
{
"_index": "offers",
"_type": "offer",
"_id": "13648190",
"_score": 1,
"_source":
{
"tags":
[
"28",
"42",
"44",
"112",
"136",
"176",
"180",
"816",
"920",
"1491"
],
"location":
{
"lon": "8.41450977",
"lat": "48.45690918"
},
"name": "Schwarzwald - 4* Wellnesshotel Palmenwald",
}
},
聚合看起来像:
"aggregations":
{
"tags_count":
{
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 3034,
"buckets":
[
{
"key": 1000,
"doc_count": 152
},
{
"key": 44,
"doc_count": 138
},
{
"key": 769,
"doc_count": 124
},
{
"key": 797,
"doc_count": 115
},
{
"key": 784,
"doc_count": 105
},
{
"key": 782,
"doc_count": 103
},
{
"key": 180,
"doc_count": 96
},
{
"key": 1038,
"doc_count": 87
},
{
"key": 999,
"doc_count": 57
},
{
"key": 42,
"doc_count": 53
}
]
}
}
问题在于汇总,它不包括在文档"标签"中找到的所有标签。整个搜索应至少有300-400个标签,并且计数似乎已关闭。