Elasticsearch plugin to classify documents

别等时光非礼了梦想. 提交于 2019-11-29 12:24:28

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
                },
            ]
        }
    }
}

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!