Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated
### Removed
### Fixed
* `Elastica\Index::refresh()` now refreshes only the targeted index instead of the entire cluster (previously it issued `POST /_refresh`, now it issues `POST /{index}/_refresh`) [#2313](https://github.com/ruflin/Elastica/issues/2313)
### Security


Expand Down
2 changes: 1 addition & 1 deletion src/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public function forcemerge($args = []): Response
public function refresh(): Response
{
return $this->_client->toElasticaResponse(
$this->_client->indices()->refresh()
$this->_client->indices()->refresh(['index' => $this->getName()])
);
}

Expand Down
19 changes: 19 additions & 0 deletions tests/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1028,4 +1028,23 @@ public function testAddDocumentWithStaleIfSeqNoFailsWithVersionConflict(): void
$this->expectException(ClientResponseException::class);
$index->addDocument($second);
}

#[Group('functional')]
public function testRefreshTargetsIndexAndNotCluster(): void
{
$index = $this->_createIndex();
$client = $index->getClient();

$response = $index->refresh();

$this->assertTrue($response->isOk());

$lastRequest = $client->getLastRequest();
$this->assertNotNull($lastRequest);
$this->assertSame(
Comment on lines +1043 to +1045
\sprintf('/%s/_refresh', $index->getName()),
$lastRequest->getUri()->getPath(),
'Index::refresh() must target the specific index, not the whole cluster'
);
}
}
Loading