elastic / elasticsearch-php

Official PHP client for Elasticsearch.
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html
MIT License
5.26k stars 966 forks source link

Where is SearchResponseIterator on 8 version? #1301

Closed hamdallah90 closed 1 year ago

hamdallah90 commented 1 year ago

Summary of problem or feature request

On 7.x branch there is SearchResponseIterator but not found on 8.x branch?

i386 commented 1 year ago

Running into the same problem. Stuck on 7.x for now.

ezimuel commented 1 year ago

We don't have SearchResponseIterator in v8. We need to add this helper feature. I can work on it for the 8.8.0 release. In the meantime, do you have any suggestion or improvement for the new SearchResponseIterator and SearchHitIterator?

hamdallah90 commented 1 year ago

sounds good

no all is good and its working 100% thank you

i386 commented 1 year ago

Works well as is afaik

hkulekci commented 1 year ago

I revised a little bit the Iterators classes on my local and created a branch here. Tests are passing but I need to test on real values. And the current problem is that SearchIterators was using a mock of the client on the older version, and we need to use the ClientInterface to mock the client, and inside the interface, the trait's methods are not defined (such as search, scroll, clearScroll, etc.). For this reason, PHPStand throwing error :

Note: Using configuration file /home/runner/work/elasticsearch-php/elasticsearch-php/phpstan.neon.
Error: Call to an undefined method Elastic\Elasticsearch\ClientInterface::clearScroll().
Error: Call to an undefined method Elastic\Elasticsearch\ClientInterface::search().
Error: Call to an undefined method Elastic\Elasticsearch\ClientInterface::scroll().
 ------ ------------------------------------------------------- 
  Line   Helper/Iterators/SearchResponseIterator.php            
 ------ ------------------------------------------------------- 
  105    Call to an undefined method                            
         Elastic\Elasticsearch\ClientInterface::clearScroll().  
  [13](https://github.com/hkulekci/elasticsearch-php/actions/runs/4441437518/jobs/7796500961#step:8:14)1    Call to an undefined method                            
         Elastic\Elasticsearch\ClientInterface::search().       
  [14](https://github.com/hkulekci/elasticsearch-php/actions/runs/4441437518/jobs/7796500961#step:8:15)3    Call to an undefined method                            
         Elastic\Elasticsearch\ClientInterface::scroll().       
 ------ -------------------------------------------------------

Any suggestion for this?

i386 commented 1 year ago

Hey @ezimuel any suggestions to what @hkulekci was having trouble with? Our team is keen to help

hkulekci commented 1 year ago

Hey @i386, I found a solution to ignore a line of code. I used a comment like this:

/* @phpstan-ignore-next-line */

This method is located in the ClientEndpointsTrait generated class, which cannot be directly added to the interface. However, I suggest we can create a base client interface using the generator script and have ClientInterface extend from it. Unfortunately, it seems that the generator script is not open source. Hope this helps!

ezimuel commented 1 year ago

We released 8.8.0 including https://github.com/elastic/elasticsearch-php/pull/1302