meilisearch-php icon indicating copy to clipboard operation
meilisearch-php copied to clipboard

Federated multi-search example does not work

Open thijskuilman opened this issue 1 year ago • 3 comments

Description I'm using the federated multi-search feature of Meilisearch. I use the code example from the docs:

$client->multiSearch([
    (new SearchQuery())
      ->setIndexUid('movies'))
      ->setQuery('batman'),
    (new SearchQuery())
      ->setIndexUid('comics')
      ->setQuery('batman'),
  ],
  (new MultiSearchFederation())
);

However, this results in the following error:

afbeelding

This error only appears when I pass an empty MultiSearchFederation() instance, like in the docs. The error does not appear when I set a property of MultiSearchFederation, like (new MultiSearchFederation())->setLimit(limit: 100).

Possible solution See my PR

thijskuilman avatar Oct 04 '24 08:10 thijskuilman

But what's the point to send without anything?

norkunas avatar Oct 04 '24 08:10 norkunas

But what's the point to send without anything?

You can to say you want to apply a federated search without any settings Federated search will merge the results of your different search, contrary to a basic multi search

So, if indeed we cannot send an empty federation, it's a bug. Or maybe there is another way to do it I ignore

curquiza avatar Oct 04 '24 10:10 curquiza

I just ran into the same issue. The problem is, that the toArray method of MultiSearchFederation returns an empty array, which php by default encodes as a json array, not object.

Lorenzschaef avatar Jan 31 '25 13:01 Lorenzschaef