Mongo aggregation on array elements. arrays,mongodb,aggregation. Using aggregation you cannot get the exact output that you want. One of the limitations of aggregation pipeline is its inability to transform values to keys in the output document. For example, Kannur is one of the values of the location field, in the input document.