如何在elasticsearch中获取唯一的json对象?

时间:2017-02-25 06:27:58

标签: json curl elasticsearch

我的文档如下:

{
            {
            "Task_Id": 3,
            "Subject": "Abhishek1"
            }
            {
            "Task_Id": 3,
            "Subject": "Abhishek2"
            }
            {
            "Task_Id": 2,
            "Subject": "Abhishe3"
            }           
}

当我搜索主题时,我想要唯一的Task_Id。

我应用了以下查询:

curl -XGET "localhost:9200/clouddemo/_search?pretty" -H "Content-Type: application/json" -d"{\"_source\":[\"Subject\",\"Task_Id\"],\"query\": {\"query_string\" : {\"default_field\" : \"Subject\",\"query\" : \"Abhi\"}},\"aggs\" : {\"distinct_id\" : {\"cardinality\" : {\"field\" : \"Task_Id\"}}}}"  (For the windows)

问题:这只是针对不同的计数,但我想要不同的计数。

预期产出:

  {
        "Task_Id": 3,
        "Subject": "Abhishek2"
        }
        {
        "Task_Id": 2,
        "Subject": "Abhishe3"
        }(only this two object not count)

0 个答案:

没有答案