#community-help

Grouping and Ordering Results in Database Queries

TLDR Maximilian asked about grouping and ordering results by number of hits per group. Kishore Nallan clarified that faceting could be used, but could not order by counts.

Powered by Struct AI
5
18mo
Solved
Join the chat
Mar 24, 2022 (18 months ago)
Maximilian
Photo of md5-d866f36ff951bfe0aae996ac8a2a5024
Maximilian
11:45 AM
hello everybody! Is it possible to group_by and order results (grouped_hits) by number of hits per group?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:51 AM
I think what you want here is faceting?
Maximilian
Photo of md5-d866f36ff951bfe0aae996ac8a2a5024
Maximilian
11:54 AM
I need to group results by 2 fields (category and brand). And I want to order results by number of items per group.

Faceting would create two lists, one grouped by category and the other grouped by brand. Is it correct?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:03 PM
Correct, there's no way to do a group by multiple fields, but order on counts.
Maximilian
Photo of md5-d866f36ff951bfe0aae996ac8a2a5024
Maximilian
02:13 PM
thanks