Sorting and Grouping Order Collections by ItemId and Price

TLDR Xing had trouble sorting and grouping order collections by item Id and lowest price. Ivan suggested using facet_by, while Kishore Nallan clarified that only desc order on highest price is possible and suggested a feature request.

Powered by Struct AI
Join the chat
Dec 22, 2022 (12 months ago)
Photo of md5-34f24f7f861b515ceeb15126c8a12a88
01:11 AM
Hi there, we met a problem of using group by and sort by together: we have a order collection and we want to group by itemId and order the groups desc on the lowest price of each group. I wonder whether there's a way to do it.
Order {
Photo of md5-bcbe2a4c9402d7445badbcf2ebdc68f8
06:53 AM
Hi, probably you can try to use facet_by instead
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:48 AM
It's not possible to order desc on the lowest price on each group.

It's only possible to order desc on the highest price of each group, which is done this way:

"group_by": "itemId",
"sort_by": "price:desc"

Once the records are grouped by itemId, the highest priced record in each group will be then used to order the groups.

Can you please create a feature request for this her: https://github.com/typesense/typesense/issues