[Feature Request] Ability to determine if a given hit has been grouped when using Distinct feature

I’ve gone through the documentation and several other posts on this topic which have all returned the same answer - that algolia does not currently support this. If I’m wrong, feel free to let me know! For reference, I’m using the instantsearch APIs for iOS and Android.

When I am displaying search results to the user, grouped results are displayed differently to singular results (I’m using algolia’s distinct feature. I have distinct = true, so one result is returned for a group). However, I am unable to determine whether a hit was grouped or not from the client side. The only option I see is to query the backend database as the user searches, which is costly and inefficient. Having the ability to know if a hit was grouped or not would save on those costs. I understand I may be oversimplifying the process by a fair amount, but really just a true or false value associated with a hit would be useful.

Thank you. Also I believe I’m posting this in the right section but let me know if not and I’ll move it

Hi there,

This is indeed not something we support at this time. Depending on your exact use case, it might be possible to put this information in your records though. Would it work in your scenario if you add a count of the number of records that belong to the same group (have the same attributeForDistinct)?

This would work for example when you have a record for all employees in a company, and you only want to show one result per company. By having an employee_count attribute in the records, anytime this count is bigger than 1 in your results, you’re sure that you’re having a grouped result.

However, the scenario above does not work if you want to have the count of filtered employees. The only way to do that for now is by performing an extra search, with distinct=false and a filter on the attribute you normally use as attributeForDistinct. As you said, this is not the most efficient, but it’s the only way for now.

I hope this helps, please let me know if you have any more questions or if I need to clarify a bit more :slightly_smiling_face:


Hi there, unfortunately yeah my use case is more similar to the latter in a filtered search. I appreciate the help! :+1: