Skip to content

Commit

Permalink
Remove version/version_type options from Index::addDocument() (#2050)
Browse files Browse the repository at this point in the history
As mentioned in #2049, the version/version_type has been removed in 7.x as concurrency control.

These options were still always added in the `addDocument` method which causes an issue when adding a document from one index to another.

This PR removes those options, and sorts the other options alphabetically cfr #1803.
  • Loading branch information
pidera committed Jan 18, 2022
1 parent 4124d20 commit 4380afd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
### Fixed
* Fixed version parameters for DeleteDocument by @pheyse24 [#2048](https://github.com/ruflin/Elastica/pull/2048)
* Fixed version parameters for Index::addDocument() by @pidera [#2050](https://github.com/ruflin/Elastica/pull/2050)
### Security

## [7.1.3](https://github.com/ruflin/Elastica/compare/7.1.2...7.1.3)
Expand Down
15 changes: 7 additions & 8 deletions src/Index.php
Expand Up @@ -198,17 +198,16 @@ public function addDocument(Document $doc): Response

$options = $doc->getOptions(
[
'version',
'version_type',
'routing',
'percolate',
'parent',
'op_type',
'consistency',
'replication',
'op_type',
'parent',
'percolate',
'pipeline',
'refresh',
'replication',
'retry_on_conflict',
'routing',
'timeout',
'pipeline',
]
);

Expand Down
22 changes: 22 additions & 0 deletions tests/IndexTest.php
Expand Up @@ -519,6 +519,28 @@ public function testAddDocumentVersion(): void
$this->assertEquals(2, $data['_version']);
}

/**
* @group functional
*/
public function testAddDocumentAcrossIndices(): void
{
$client = $this->_getClient();
$index1 = $client->getIndex('test');
$index2 = $client->getIndex('test_2');

$doc = new Document(1);
$doc->set('title', 'Hello world');

$index1->addDocument($doc);

$index1Doc = $index1->getDocument(1);

$index2->addDocument($index1Doc);
$index2Doc = $index1->getDocument(1);

$this->assertEquals('Hello world', $index2Doc->get('title'));
}

/**
* @group functional
*/
Expand Down

0 comments on commit 4380afd

Please sign in to comment.