In Factual how to get results with unique field values (similar to GROUP BY in SQL)?

41 Views Asked by At

I've just set out on the path to discovery of Factual API and I cannot see how to achieve a retrieval of a selection of entries each with a unique value in the specified field.

For example, give me 10 results from various cities:

q.limit(10);
q.field("locality").unique();  // no such filter exists
factual.fetch("places", q);

This would be an equivalent query in MySQL:

SELECT * FROM places GROUP BY locality LIMIT 10;

What I want is a little bit similar to facets:

FacetQuery fq = new FacetQuery("locality").maxValuesPerFacet(10);
fq.field("country").isEqual("gb");
FacetResponse resp = factual.fetch("places", fq);

but instead of the total for each result I would like to see a random object with all the information.

Is anything like this possible?

0

There are 0 best solutions below