Ashutosh
04/18/2025, 10:56 AMgroup_by
feature and would really appreciate your help or any pointers.
š§ Problem 1: Sorting group_by
response based on grouped_hit
count
I'm using the group_by
parameter on supplierInfo
to group parts by supplier.
The issue is that the response is not sorted based on the number of grouped_hits
, which is something I need.
š Why this sorting is important:
I want to differentiate suppliers based on how many parts they are fulfilling from the requested set.
However, Typesense has limits:
⢠Max 250 groups
⢠Max 100 grouped_hits
per group
These limits create a situation where even if the 200th group fulfills all requested parts (100%), it may:
⢠Not appear on top
⢠Or not appear at all in the response
ā ļø Sorting on the frontend is heavy and hard to manage, especially when the full context is missing due to the limits.
I believe pushing this logic closer to the source (Typesense) is more efficient.š§ Problem 2: Sorting based on fulfillment % (ordered quantity vs available quantity) Along with
grouped_hit
count, I also want to sort suppliers based on how well they fulfill the quantity.
š Example:
If 2 suppliers both match 3 parts:
⢠Supplier A provides 100% of the requested quantities
⢠Supplier B provides only 50ā70% of the quantities
Even though the number of hits (parts matched) is the same,
I want Supplier A to appear before Supplier B based on fulfillment %.
ā
Requirements:
All suppliers (even partial ones) should still appear.
The sort order should prioritize:
1. Higher number of parts matched
2. Then higher % of quantity fulfilled
ā Current Issue:
The current response from Typesense (via adapter) seems to return groups in random order, without a way to control:
⢠Sorting based on grouped_hit.length
⢠Or a custom criteria like fulfillment %
ā*My Question:*
Is there a native way in Typesense or via the adapter to sort group_by
results based on:
⢠grouped_hit.length
(number of hits per group), or
⢠A custom criteria like fulfillment percentage?
If not, any ideas or workarounds (adapter-level or Typesense-level) would be really helpful!
š Thanks in advance!