Elasticsearch 插件对文档进行分类 [英] Elasticsearch plugin to classify documents

查看:38
本文介绍了Elasticsearch 插件对文档进行分类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个弹性搜索插件可以让我对我在索引中输入的文档进行分类?

Is there an elasticsearch plugin out there that would allow me to classify the documents that I enter in an index?

对我来说最好的解决方案是对所有最常出现的术语(/概念)进行分类,这些术语(/概念)显示在一种用户可以导航的标签云中.

The best solution for me would be a classifications of all the most recurrent terms (/ concepts) displayed in a sort of tags cloud that the user can navigate.

有没有办法做到这一点?有什么建议吗?

Is there a way to achieve this? Any suggestions?

谢谢

推荐答案

基本思想是使用一个 terms 聚合,每个术语将产生一个桶.

The basic idea is to use a terms aggregations, which will yield one bucket per term.

POST /_search
{
    "aggs" : {
        "genres" : {
            "terms" : { "field" : "genre" }
        }
    }
}

您将得到的回复将按术语出现次数的减少排序:

The response you'll get will be ordered by decreasing amount of term occurrences:

{
    ...

    "aggregations" : {
        "genres" : {
            "doc_count_error_upper_bound": 0, 
            "sum_other_doc_count": 0, 
            "buckets" : [ 
                {
                    "key" : "jazz",
                    "doc_count" : 10
                },
                {
                    "key" : "rock",
                    "doc_count" : 5
                },
                {
                    "key" : "electronic",
                    "doc_count" : 2
                },
            ]
        }
    }
}

如果你使用 Kibana,你可以直接创建一个 标签云基于这些术语的可视化.

If you're using Kibana, you can directly create a tag cloud visualization based on those terms.

这篇关于Elasticsearch 插件对文档进行分类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆