Feature Request: Configurable Limit for distinctAttribute #894
yrdguezro
started this conversation in
Feedback & Feature Proposal
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
In e-commerce search scenarios, products often have multiple variants (e.g., up to 100 different color options). Currently, Meilisearch supports distinctAttribute, which successfully removes duplicates by ensuring only one document per distinct value (e.g., product_id) is returned.
However, this creates a limitation when a search interface requires displaying a product card that highlights the top matching elements within that group such as showing the top 3 specific colors/variants that best match the search query. Right now, because distinct strictly caps results to 1 per group, developers are forced to perform complex workarounds like maintaining secondary indices or executing multiple requests via /multi-search.
I would like to propose extending Meilisearch's distinct functionality to support a configurable record limit per group, similar to how Algolia handles it.
Specifically, allow developers to specify a numeric limit alongside the distinct attribute (or via search parameters/settings) to define how many documents should be returned for each unique group.
{ "q": "red running shoes", "distinct": "product_id", "distinctLimit": 4 }All reactions