Open magikid opened 1 year ago
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?
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?
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.