From f957d884dd8f10e826d9d68acf14a8ce558b1053 Mon Sep 17 00:00:00 2001 From: Ruflin Date: Mon, 11 May 2015 14:12:48 +0200 Subject: [PATCH 1/5] Prepare composer file for release --- changes.txt | 1 + composer.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/changes.txt b/changes.txt index dd9beaa337..2bdf8b3768 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,7 @@ CHANGES 2015-05-11 +- Release 2.0.0 - Add testing on PHP 7 on Travis #826 2015-05-06 diff --git a/composer.json b/composer.json index 31904da089..4c92c97e9d 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "2.0.x-dev" } } } From 93a11677cfe8fad7aca43f63a8679423591ceb4d Mon Sep 17 00:00:00 2001 From: Ruflin Date: Mon, 11 May 2015 14:21:26 +0200 Subject: [PATCH 2/5] Complete changes.txt file --- changes.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/changes.txt b/changes.txt index 2bdf8b3768..2fbaa4393a 100644 --- a/changes.txt +++ b/changes.txt @@ -18,18 +18,18 @@ CHANGES - Add MLT query against documents #814 2015-04-09 -- Added Elastica\Query\SimpleQueryString::setMinimumShouldMatch -- Added Elastica\Query\FunctionScore::setMinScore -- Added Elastica\Query\MoreLikeThis::setMinimumShouldMatch +- Added Elastica\Query\SimpleQueryString::setMinimumShouldMatch #813 +- Added Elastica\Query\FunctionScore::setMinScore #813 +- Added Elastica\Query\MoreLikeThis::setMinimumShouldMatch #813 2015-04-08 -- Added new methods to Elastica\Aggregation\DateHistogram: setOffset, setTimezone -- Following methods in Elastica\Aggregation\DateHistogram marked as deprecated: setPreOffset, setPostOffset, setPreZone, setPostZone, setPreZoneAdjustLargeInterval +- Added new methods to Elastica\Aggregation\DateHistogram: setOffset, setTimezone #813 +- Following methods in Elastica\Aggregation\DateHistogram marked as deprecated: setPreOffset, setPostOffset, setPreZone, setPostZone, setPreZoneAdjustLargeInterval #813 - Add Elastica\Facet\DateHistogram::setFactor() #806 2015-04-07 -- [BC break] Elastica\Query\QueryString::setLowercaseExpandedTerms removed -- Added Elastica\Query\QueryString::setTimezone +- [BC break] Elastica\Query\QueryString::setLowercaseExpandedTerms removed #813 +- Added Elastica\Query\QueryString::setTimezone #813 2015-04-06 - Update Elasticsearch version to 1.5 #813 From 1aab52eea05412b5400c81a623fc3d8b0449495a Mon Sep 17 00:00:00 2001 From: Ruflin Date: Mon, 11 May 2015 14:42:59 +0200 Subject: [PATCH 3/5] Update changes.txt file --- changes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes.txt b/changes.txt index 2fbaa4393a..16de0391f1 100644 --- a/changes.txt +++ b/changes.txt @@ -33,7 +33,7 @@ CHANGES 2015-04-06 - Update Elasticsearch version to 1.5 #813 -- Added deprecation notice to Elastica\Transport\Thrift, Elastica\Transport\Memcached and Elastica\Type::deleteByQuery +- Added deprecation notice to Elastica\Transport\Thrift, Elastica\Transport\Memcached and Elastica\Type::deleteByQuery #813 2015-04-03 - Add .editorconfig #807 From 49017b3060a3b14ab5767507969fa1ac5bff9441 Mon Sep 17 00:00:00 2001 From: Ruflin Date: Wed, 13 May 2015 08:41:43 +0200 Subject: [PATCH 4/5] Remove set scroll options in copy function as already done in ScanAndScroll --- lib/Elastica/Util.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Elastica/Util.php b/lib/Elastica/Util.php index 591a38d12d..4e0470110e 100644 --- a/lib/Elastica/Util.php +++ b/lib/Elastica/Util.php @@ -203,7 +203,6 @@ public static function copy(Index $oldIndex, Index $newIndex, $expiryTime = '1m' $bulk->setIndex($newIndex); $search->addIndex($oldIndex); - $search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_SCAN); $scanAndScroll = new ScanAndScroll($search, $expiryTime, $sizePerShard); foreach ($scanAndScroll as $resultSet) { From d4fa02363fab297f7a1587f1479c5f4d17ca5fc1 Mon Sep 17 00:00:00 2001 From: Ruflin Date: Wed, 13 May 2015 09:29:31 +0200 Subject: [PATCH 5/5] Remove copy function for release to not have BC breaks afterwards --- changes.txt | 3 -- lib/Elastica/Util.php | 35 --------------- test/lib/Elastica/Test/UtilTest.php | 67 ----------------------------- 3 files changed, 105 deletions(-) diff --git a/changes.txt b/changes.txt index 486e49bd2a..4c83343090 100644 --- a/changes.txt +++ b/changes.txt @@ -5,9 +5,6 @@ CHANGES - Update elasticsearch dependency to elasticsearch 1.5.2 https://www.elastic.co/downloads/past-releases/elasticsearch-1-5-2 #834 - Add testing on PHP 7 on Travis #826 -2015-05-06 -- Add Elastica\Util::copy function by scan and bulk way http://www.elastic.co/guide/en/elasticsearch/guide/master/reindex.html. Note: This was first called reindex #829 #931 ##836 - 2015-04-23 - Allow bool in Query::setSource function #818 http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html - Fix empty bool query to act as match all query #817 diff --git a/lib/Elastica/Util.php b/lib/Elastica/Util.php index 4e0470110e..74330ef69f 100644 --- a/lib/Elastica/Util.php +++ b/lib/Elastica/Util.php @@ -186,39 +186,4 @@ public static function convertRequestToCurlCommand(Request $request) return $message; } - - /** - * Copy all data from and old index to a new index - * - * @param \Elastica\Index $oldIndex - * @param \Elastica\Index $newIndex - * @param string $expiryTime - * @param int $sizePerShard - * @return \Elastica\Index The new index object - */ - public static function copy(Index $oldIndex, Index $newIndex, $expiryTime = '1m', $sizePerShard = 1000) - { - $search = new Search($oldIndex->getClient()); - $bulk = new Bulk($newIndex->getClient()); - $bulk->setIndex($newIndex); - - $search->addIndex($oldIndex); - $scanAndScroll = new ScanAndScroll($search, $expiryTime, $sizePerShard); - - foreach ($scanAndScroll as $resultSet) { - $data = $resultSet->getResponse()->getData(); - $actions = array(); - foreach ($data['hits']['hits'] as $d) { - $meta = array('_index' => $newIndex->getName() , '_type' => $d['_type'], '_id' => $d['_id']); - $actions[] = new Action(Action::OP_TYPE_INDEX, $meta ,$d['_source']); - } - //$actions = new Bulk\Action(); - $bulk->addActions($actions); - $bulk->send(); - } - - $newIndex->refresh(); - - return $newIndex; - } } diff --git a/test/lib/Elastica/Test/UtilTest.php b/test/lib/Elastica/Test/UtilTest.php index 35cb7fabe9..17ea01605a 100644 --- a/test/lib/Elastica/Test/UtilTest.php +++ b/test/lib/Elastica/Test/UtilTest.php @@ -118,71 +118,4 @@ public function testConvertDateTimeObjectWithoutTimezone() $this->assertEquals($convertedString, $date); } - - public function testCopy() - { - $client = $this->_getClient(); - $oldIndex = $client->getIndex("elastica_test_reindex"); - $oldIndex->create(array( - 'number_of_shards' => 4, - 'number_of_replicas' => 1, - ),true); - - $newIndex = $client->getIndex("elastica_test_reindex_v2"); - $newIndex->create(array( - 'number_of_shards' => 4, - 'number_of_replicas' => 1, - ),true); - - $type1 = $oldIndex->getType("test1"); - $type2 = $oldIndex->getType("test2"); - - $documents1[] = $type1->createDocument(1, array('name' => 'Xwei1')); - $documents1[] = $type1->createDocument(2, array('name' => 'Xwei2')); - $documents1[] = $type1->createDocument(3, array('name' => 'Xwei3')); - $documents1[] = $type1->createDocument(4, array('name' => 'Xwei4')); - - $documents2[] = $type2->createDocument(1, array('name' => 'Xwei5')); - $documents2[] = $type2->createDocument(2, array('name' => 'Xwei6')); - $documents2[] = $type2->createDocument(3, array('name' => 'Xwei7')); - $documents2[] = $type2->createDocument(4, array('name' => 'Xwei8')); - - $type1->addDocuments($documents1); - $type2->addDocuments($documents2); - - $oldIndex->refresh(); - - - $this->assertInstanceOf('Elastica\Index', Util::copy($oldIndex, $newIndex,"1m",1)); - - $newCount = $newIndex->count(); - $this->assertEquals(8, $newCount); - } - - public function testCopyFail() - { - $client = $this->_getClient(); - - $oldIndex = $client->getIndex("elastica_test_reindex"); - $oldIndex->create(array( - 'number_of_shards' => 4, - 'number_of_replicas' => 1, - ), true); - - $newIndex = $client->getIndex("elastica_test_reindex_v2"); - $newIndex->create(array( - 'number_of_shards' => 4, - 'number_of_replicas' => 1, - ), true); - - $newIndex2 = $client->getIndex("elastica_test_reindex_v2"); - $newIndex2->delete(); - - try { - Util::copy($oldIndex, $newIndex); - $this->fail('New Index should not exist'); - } catch (ResponseException $e) { - $this->assertContains('IndexMissingException', $e->getMessage()); - } - } }