Bulk Query - Get Unique results

If I have data in ES that looks like this:
{ (name: 'Steve Rogers', city: 'New York', color: 'Blue'),
(name: 'Tony Stark', city; 'Los Angeles', color 'gold'),
(name: 'Bruce Banner', city: 'New York', color: 'green'),
(name: 'Peter Parker', city: 'New York', color: 'red'),
I want to run a bulk query and pull out all the unique names. If my data is 17M records, how can I pull back all the
data quickly ? All in JAVA

I'd also like to run a query and bring back all the unique combinations of name, city.