我能够使用旧的elasticsearch版本使用术语聚合来获取word云。我想从在es5中发布内容获得word云,我正在使用下面的查询。
"aggs": {
"tagcloud": {
"terms": {
"field": "content.raw",
"size": 10
}
}
}我做过这样的测绘
"content": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
}但结果并没有像预期的那样成为一个词云。它将类似的帖子(整篇文章)进行分组,并给出如下列表。
"buckets": [
{
"key" : "This car is awesome.",
"doc_count" : 199
},
..
..怎么做?
发布于 2017-01-18 14:43:22
keyword类型与具有not_analyzed索引模式的string几乎相同。整个字符串都是索引的。你只能用精确的值来搜索。在您的示例中,我认为您需要使用分析和标记的字段,例如content字段。但是,您需要确保字段的选项fielddata设置为true。否则,服务器将返回异常。因此,您的映射应该类似于
"content": {
"fielddata" : true,
"type": "text"
}和聚集
"aggs": {
"tagcloud": {
"terms": {
"field": "content",
"size": 10
}
}
}因此,您应该看到类似的东西(这取决于您所选择的分析器)。
"buckets": [
{
"key" : "this",
"doc_count" : 199
},
{
"key" : "car",
"doc_count" : 199
},
{
"key" : "is",
"doc_count" : 199
},
{
"key" : "awesome",
"doc_count" : 199
},
...https://stackoverflow.com/questions/41721417
复制相似问题