Allow selecting DISTINCT values on datastore_search

(This is needed for #1792)

It would be useful to be able to query `datastore_search` with something like:

```json
{
    "resource_id": "the_resource_id",
    "q": "Wash",
    "fields": "state",
    "unique": true
}
```

And then it would return only distinct rows with these parameters.

As we're modifying the datastore quite heavily on #1725, it's good to start working on this only after that's merged.