Inconsistent results when aggregate by field from array