elastic-search icon indicating copy to clipboard operation
elastic-search copied to clipboard

'Refresh' behavior

Open andrii-pukhalevych opened this issue 4 years ago • 2 comments

Currently, 'refresh'=>true option for save() and saveMany() causing additional elastic query $esIndex->refresh().

I see that it is possible to pass refresh parameter in primary request: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html#bulk-refresh https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#docs-update-api-query-params

Should not we remove $esIndex->refresh() in favor of passing 'refresh'=>true in primary request?

andrii-pukhalevych avatar Feb 10 '22 11:02 andrii-pukhalevych

public function saveMany($entities, $options = [])
....
	$requestParams = [];
	if ($options['refresh']) {
		$requestParams['refresh'] = 'wait_for';
	}

	$esIndex = $this->getConnection()->getIndex($this->getName());
	$esIndex->addDocuments($documents, $requestParams);

And remove below:

if ($options['refresh']) {
	$esIndex->refresh();
}

andrii-pukhalevych avatar Feb 10 '22 11:02 andrii-pukhalevych

Makes sense to me. I don't think the refresh option existed when saving was first implemented, but now that it exists we should use it.

markstory avatar Feb 15 '22 05:02 markstory

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Dec 22 '22 00:12 github-actions[bot]