0

Using Meilisearch for the first time in my web app and it's working great except that queries give 20 hits tops where I should get 100+. So I read the docs and hitsPerPage seems to be the option to increase. But I'm struggling with the syntax to send the parameter with my search request. In my model I have

  protected $with = [
    'system'
  ];

  public function toSearchableArray(): array
  {
    return [
      'name' => $this->name,
      'system' => [
        'name' => $this->system->name,
        'altname' => $this->system->altname ?? '',
        'owner' => $this->system->owner ?? ''
      ]
    ];
  }

  public static function getSearchResult($s)
  {
    $options['hitsPerPage'] = 500; 
    $games = Game::search(query:trim($s) ?? '', $options);
    return $games;
  }

which results in error Cannot use positional argument after named argument. Leaving out query: renders the search request being unable to deal with nullable columns like system.owner and shows exception Attempt to read property "owner" on null. So I guess it would be best to name the options.

Rome
  • 432
  • 6
  • 27

0 Answers0