Get unique records with highest attribute value

Let’s take a scenario where I have two records such as,

{
   'shirtModel':'A',
   'store': 'XYZ store',
   'customersPurchased': 8
},
{
   'shirtModel':'A',
   'store': 'ABC store',
   'customersPurchased': 10
},

In the above two records I need to get the store value with highest number of customers purchased the ‘A’ shirt model. How can I do it?

1 Like

Hi Subhas,

That should be as easy as configuring your index with a custom ranking on customersPurchased sorted descending. The first hit for a search should be the top ranking record.

Read more here: Create Custom Ranking Attributes | How to | Managing Results | Guide | Algolia Documentation

2 Likes

Thanks @chuck.meyer. It solved my problem