Is it possible to construct unique by queries? For...
# community-help
d
Is it possible to construct unique by queries? For example, picture an ecommerce store. I'd like to get 4 search hits from a specific category, but only one of each product name. So if I'm selling phones, instead of getting 1. Apple iPhone 12 2. Apple iPhone 13 3. Apple iPhone 14 4. Samsung Galaxy S23 I'd like to get 1. Apple iPhone 12 2. Samsung Galaxy S23 3. Google Pixel 6a 4. OnePlus 11 (Apple, Samsung, Google, OnePlus would be of a key named "brand" that I'd like the results to be uniq by)
j
yeah, you can do
group_by=brand
and
group_limit=1
to get one from each group
3
d
Thank you @John!
j
What if I want to get all the unique values of a field of an entire collection? the group_by and group_limit solution only surfaces unique values that are in the paginated search results, which are limited to 250 results per page
j
You should be able to use facet_by for that
🙌 1
There’s some max_facet_values parameter or similar you might have to adjust
j
Beautiful! Facet by returns the unique values, many thanks sir
j
No worries :)