Elasticsearch plugin to classify documents

后端 未结 1 1483
梦如初夏
梦如初夏 2020-12-20 02:38

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 classification

相关标签:
1条回答
  • 2020-12-20 03:09

    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.

    0 讨论(0)
提交回复
热议问题