Elasticsearch plugin to classify documents

假装没事ソ 提交于 2019-11-28 05:56:47

问题


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?

Thanks


回答1:


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.



来源:https://stackoverflow.com/questions/42889605/elasticsearch-plugin-to-classify-documents

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