Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return more than 10 rows bug #23

Closed
mauxtin opened this issue May 31, 2019 · 1 comment · Fixed by #24
Closed

Return more than 10 rows bug #23

mauxtin opened this issue May 31, 2019 · 1 comment · Fixed by #24
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mauxtin
Copy link
Contributor

mauxtin commented May 31, 2019

Shouldn't these two return the same result?

   $results = Product::search('*')->get(); // ok - returns collection with 10 products
   $results = Product::search('*', function (Client $client, Search $body) {
      $body->setSize(100);
      $client->search(['index' => 'products', 'body' => $body->toArray()]);
   })->get(); // returns empty collection

At first the second query returns an error

Argument 1 passed to Matchish\ScoutElasticSearch\ElasticSearch\EloquentHitsIteratorAggregate::__construct() must be of the type array, null given, called in \xxx\vendor\matchish\laravel-scout-elasticsearch\src\Engines\ElasticSearchEngine.php on line 106

which I solved by editing the EloquentHitsIteratorAggregate constructor from

public function __construct(array $results, callable $callback = null)

to

public function __construct(?array $results, callable $callback = null)

(I did not make a PR for this since I just started working with the package and I am not sure if this is actually a bug. Let me know if you need me to make a quick PR)

@mauxtin mauxtin changed the title Return more than 10 rows Return more than 10 rows bug May 31, 2019
@matchish
Copy link
Owner

matchish commented May 31, 2019

Thanks for the issue. I think return statement should solve the issue

   $results = Product::search('*', function (Client $client, Search $body) {
      $body->setSize(100);
      return $client->search(['index' => 'products', 'body' => $body->toArray()]);
   })->get(); // returns empty collection

So probably example in README has mistake
Feel free to make PR to fix README if return statement will solve the issue

@matchish matchish added bug Something isn't working good first issue Good for newcomers labels May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants