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

[BUG] Scrolling triggers deprecation error #163

Open
magikid opened this issue Jul 25, 2023 · 1 comment
Open

[BUG] Scrolling triggers deprecation error #163

magikid opened this issue Jul 25, 2023 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@magikid
Copy link

magikid commented Jul 25, 2023

What is the bug?

When using a OpenSearch\Helper\Iterators\SearchResponseIterator, the deprecation error 'A scroll id can be quite large and should be specified as part of the body' is thrown.

How can one reproduce the bug?

$iterator = new SearchResponseIterator($client, $parameters);
foreach ($pageIterator as $page) {
    echo 'Error occurs here';
}

What is the expected behavior?

I would expect the iterator to use the scroll API properly without throwing a deprecation.

What is your host/environment?

Debian GNU/Linux 11 (bullseye)

Do you have any screenshots?

Nope

Do you have any additional context?

None that I can think of but I'm happy to answer questions about this.

@magikid magikid added bug Something isn't working untriaged labels Jul 25, 2023
@wbeckler wbeckler added the good first issue Good for newcomers label Sep 19, 2023
@imdhemy
Copy link
Contributor

imdhemy commented Mar 7, 2024

Hi 👋

I tried the following code with PHPUnit and it passed:

Item Version
OpenSearch v2
PHP v8.3
opensearch-php main
public function integration_test(): void
    {
        $client = ClientBuilder::create()
            ->setHosts([Utility::getHost()])
            ->setLogger(new ArrayLogger())
            ->setSSLVerification(false)->build();

        // unique index name
        $index = "test_index_".time();

        // populate index with 100 documents
        for ($i = 0; $i < 100; $i++) {
            $client->index(
                [
                    'index' => $index,
                    'body' => [
                        'test_field' => 'test_value'
                    ]
                ]
            );
        }

        // refresh the index for testing
        $client->indices()->refresh(['index' => $index]);

        // test the iterator
        $search_params = [
            'scroll'      => '5m',
            'index'       => $index,
            'size'        => 10,
            'body'        => [
                'query' => [
                    'match_all' => new stdClass()
                ]
            ]
        ];
        $pages = new SearchResponseIterator($client, $search_params);
        $count = 0;

        // iterate over the pages and count the documents
        foreach ($pages as $page) {
            $count += count($page['hits']['hits']);
            $documents = $page['hits']['hits'];
            foreach ($documents as $document) {
                // check if the document is accessible
                $this->assertEquals('test_value', $document['_source']['test_field']);
            }
        }

        $this->assertEquals(100, $count);
    }

I'm willing to fix this bug if it exists. Did I miss something?

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

No branches or pull requests

4 participants