Good morning, quick question about Union (federate...
# community-help
t
Good morning, quick question about Union (federated) search + `group_by`: when I use
group_by
to aggregate results in a union search the
found
-integer returns an incorrect number of results. In my case it is
84
, whereas the actual (grouped) hits only has a size of
7
. I can't use pagination on our website without the correct number of results. Is there a way to obtain the correct number of actual results?
My searches-body looks similar to this:
Copy code
const body = {
  union: true,
  searches: [
    {
      collection: "collection_a",
      q: "search term",
      query_by: "field1,field2",
      group_by: "field_x",
      include_fields: "field1",
    },
    {
      collection: "collection_b",
      q: "search term",
      query_by: "field3,field4",
      group_by: "field_x",
      include_fields: "field3",
    },
  ],
};
f
Could you post a small reproducible example like this one?
👍 1
t
@Fanis Tharropoulos thanks for the clear template, nice find! https://github.com/Raanelom/typesense-reproduction-group-by-multisearch here is my reproduction: it should return
found: 2
but returns
found: 3
and 2 actual results
f
Hey Tim, Could you upgrade to
v30.0.rca34
? The issue is not reproducible there
t
Oh cool, I'll try
Ok awesome, this also fixed the union_search_params count
Tyvm
The only thing is that the sorting is kinda weird. One collection is always preferred over the other, on a per-page basis. So I always see some results of collection_1 at first, and collection_2 at the bottom of every page
Nevermind, it seems to work right now
🙌 1