Grouping using multiple fields

The objective is to group by two fields and then sum the corresponding amounts. Equivalent to the SQL query:
select empID, empName , SUM(salary) FROM random GROUP BY empId, empName.

I used terms aggregation but it does not seem to work correctly when I use two terms. Basically at the end I would like to have one dictionary with the key as (empId + empName) and the value as the summed salary. But my attempts have resulted in created a nested grouping with two levels and thus incorrect results.

I am using the NEST client for .net.

1 Like