Skip to content

Commit

Permalink
Add for opening a PiT on the index
Browse files Browse the repository at this point in the history
  • Loading branch information
thePanz committed Oct 8, 2021
1 parent 0cadecb commit 6220cc7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added support for `psr/log` 2.0 and 3.0 [#1971](https://github.com/ruflin/Elastica/pull/1971)
* Added new optional 'case_insensitive' option to `Elastica\Query\Wildcard` [#1894](https://github.com/ruflin/Elastica/pull/1894)
* Added `Elastica\Result::getSort()` fetching the "sort" property of results [#1979](https://github.com/ruflin/Elastica/pull/1979)
* Added `Elastica\Index::openPointInTime()` for opening a PiT on the index [#1994](https://github.com/ruflin/Elastica/pull/1994)
### Changed
* Updated `php-cs-fixer` to `2.18.6` [#1955](https://github.com/ruflin/Elastica/pull/1955)
* Updated `php-cs-fixer` to `3.0.0` [#1959](https://github.com/ruflin/Elastica/pull/1959)
Expand Down
14 changes: 14 additions & 0 deletions src/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use Elasticsearch\Endpoints\Indices\Refresh;
use Elasticsearch\Endpoints\Indices\Settings\Put;
use Elasticsearch\Endpoints\Indices\UpdateAliases;
use Elasticsearch\Endpoints\OpenPointInTime;
use Elasticsearch\Endpoints\UpdateByQuery;

/**
Expand Down Expand Up @@ -322,6 +323,19 @@ public function deleteByQuery($query, array $options = []): Response
return $this->requestEndpoint($endpoint);
}

/**
* Opens a Point-in-Time on the index.
*
* @see: https://www.elastic.co/guide/en/elasticsearch/reference/current/point-in-time-api.html
*/
public function openPointInTime(string $keepAlive): Response
{
$endpoint = new OpenPointInTime();
$endpoint->setParams(['keep_alive' => $keepAlive]);

return $this->requestEndpoint($endpoint);
}

/**
* Deletes the index.
*/
Expand Down
15 changes: 15 additions & 0 deletions tests/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,21 @@ public function testDeleteIndexDeleteAlias(): void
$this->assertFalse($status->aliasExists($aliasName));
}

/**
* @group functional
*/
public function testOpenPointInTime(): void
{
$index = $this->_createIndex();
$response = $index->openPointInTime('10s');

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

$data = $response->getData();
$this->assertIsArray($data);
$this->assertArrayHasKey('id', $data);
}

/**
* @group functional
*/
Expand Down

0 comments on commit 6220cc7

Please sign in to comment.