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

Add exposure of Point-In-Time ID for search responses #1991

Merged
merged 2 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions src/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
1 change: 1 addition & 0 deletions tests/ResultSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down