Able to sort which hit is shown when deduplicating using distinct = 1

Consider 5 hits that represent 2 products with some variations.

[
	{
		"title": "Product A",
		"variation": "Size: 1",
		"price": 55,
		"popularity": 11
	},
	{
		"title": "Product A",
		"variation": "Size: 2",
		"price": 60,
		"popularity": 21
	},
	{
		"title": "Product B",
		"variation": "Size: 1",
		"price": 70,
		"popularity": 4
	},
	{
		"title": "Product B",
		"variation": "Size: 2",
		"price": 80,
		"popularity": 61
	},
	{
		"title": "Product B",
		"variation": "Size: 3",
		"price": 90,
		"popularity": 4
	}
]

If you perform a search with distinct=1 and attributeForDistinct=title and also have rankingAndSorting with a popularity as a custom ranking attribute you should get the following result.

[
	{
		"title": "Product B",
		"variation": "Size: 2",
		"price": 80,
		"popularity": 61
	},
	{
		"title": "Product A",
		"variation": "Size: 2",
		"price": 60,
		"popularity": 21
	}
]

What if I wanted to show the lowest price for these results (to show “costs from £70” wrt product B). However I don’t want to alter to overall order as Product B should be ranked above Product A based on the popularity. If I sorted by price it would select the hit with minimum price but the order would be incorrect. I am unable to add an attribute that would list the min price for a selected group within each individual hit as this search also needs to work if for example someone filtered out Size 1. Is there currently a way to sort which individual hit is selected to be shown as part of a distinct search?

1 Like

I too have this same issue. I’m breaking up the content/copy of a blog post then using attributeForDistinct=1. However, I want to assure the default view of the post in search results displays the blog post content in the correct order (top to bottom). It currently seems random and sometimes show the last chunk of content which looks odd (imagine a blog post final thoughts).