diff --git a/CHANGELOG.md b/CHANGELOG.md index 646c9863ce..eacb47b6f3 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 exposure of Point-In-Time ID for search responses in `Elastica\ResultSet::getPointInTimeId()` [#1991](https://github.com/ruflin/Elastica/pull/1991) * 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) diff --git a/src/ResultSet.php b/src/ResultSet.php index 1db6613850..fe6352d62c 100644 --- a/src/ResultSet.php +++ b/src/ResultSet.php @@ -177,6 +177,18 @@ public function getTotalTime(): int return $data['took'] ?? 0; } + /** + * Returns the Point-In-Time ID, if available. + * + * @See: https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after + */ + public function getPointInTimeId(): ?string + { + $data = $this->_response->getData(); + + return $data['pit_id'] ?? null; + } + /** * Returns true if the query has timed out. */ diff --git a/tests/ResultSetTest.php b/tests/ResultSetTest.php index 3638f14c15..a05fbc8dee 100644 --- a/tests/ResultSetTest.php +++ b/tests/ResultSetTest.php @@ -34,6 +34,7 @@ public function testGetters(): void $this->assertNotTrue($resultSet->hasAggregations()); $this->assertNotTrue($resultSet->hasSuggests()); $this->assertIsArray($resultSet->getResults()); + $this->assertNull($resultSet->getPointInTimeId()); $this->assertCount(3, $resultSet); }