How to get single data from aggregation filter

I need an idea that will help me to get only first data for related key. This is my output and I need elasticsearch to return each keyword only once.

"Group3": {
                  "buckets": [
                    {
                      "doc_count": 1, 
                      "key": "sleep"
                    }
                  ], 
                  "doc_count_error_upper_bound": 0, 
                  "sum_other_doc_count": 0
                }, 
                "doc_count": 56, 
                "key": 18
              }, 
              {
                "Group3": {
                  "buckets": [
                    {
                      "doc_count": 1, 
                      "key": "sleep"
                    }
                  ], 
                  "doc_count_error_upper_bound": 0, 
                  "sum_other_doc_count": 0
                }, 
                "doc_count": 58, 
                "key": 17
              }, 
              {
                "Group3": {
                  "buckets": [
                    {
                      "doc_count": 1, 
                      "key": "a"
                    }, 
                    {
                      "doc_count": 1, 
                      "key": "sleep"
                    }
                  ], 
                  "doc_count_error_upper_bound": 0, 
                  "sum_other_doc_count": 0
                }, 
                "doc_count": 60, 
                "key": 16
              }, 

Here I have some "sleep" data and I want to see this data for only "key":18 part. I want elasticsearch to ignore thes rest of "sleep" data. Same goes with "a" data. I want to see this data for "key":16 part. And for that part I don't want to see "sleep" data. Any idea?

Can anyone please help?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.