Get distinct records from a search query

Hi,
How can i get a distinct record set from a query in elastic search :My query is as follows :slight_smile:{
"_source": [
"dealname",
"deal_key"
],
"query": {
"match": {
"dealname": {
"query": "Babson 2004",
"operator": "and"
}
}
}
}

and the result that i am getting back is:

"_source": {
"dealname": "Babson CLO Ltd. 2004-I",
"deal_key": "500029871"
}

"_source": {
"dealname": "Babson CLO Ltd. 2004-I",
"deal_key": "500029871"
}

"_source": {
"dealname": "Babson CLO Ltd. 2004-I2",
"deal_key": "500029871"
}

But as you see there are only 2 distinct records in the output
1:deal_key 500029871 and dealname Babson CLO Ltd. 2004-I
2:deal_key 500029871 and dealname Babson CLO Ltd. 2004-I2

But the output gives me 3 result set .How can i refine this?

You have to use a Terms aggregation