How do I get all the distinct field values that satisfy a particular query