How to aggreegate Couchbase data Using Spring boot

i have couchbase document in below format,i want aggregate the object inside the array, is there any Aggregation method or template is available in couchbase,

    {"Students":[
    {
    "Student_id": "101"
    "Name": "Jon",
    "Course" : "Engineer"
    },
    {
    "Student_id": "102"
    "Name": "Snow",
    "Course" : "Medical"
    },
    {
    "Student_id": "103"
    "Name": "Walter",
    "Course" : "Chemistry"
    },
    {
    "Student_id": "104"
    "Name": "White",
    "Course" : "Chemistry"
    }
    ]
} 

Output like:
Students : 4
Chemistry Students : 2

Any help will be appreciate!!Thanks in Advance

INSERT INTO default VALUES("f001",{"Students":[ { "Student_id": "101", "Name": "Jon", "Course" : "Engineer" }, { "Student_id": "102", "Name": "Snow", "Course" : "Medical" }, { "Student_id": "103", "Name": "Walter", "Course" : "Chemistry" }, { "Student_id": "104", "Name": "White", "Course" : "Chemistry" } ] } );
SELECT (OBJECT v.Course||"Students":v.cnt
       FOR v IN ARRAY_APPEND(ds, {"Course":"", "cnt": ARRAY_SUM(ds[*].cnt)})
       END).*
LET ds = ( SELECT s.Course|| " " AS Course , COUNT(1) AS cnt
           FROM default AS d
           UNNEST d.Students AS s
           GROUP BY s.Course);