diff --git a/changes.txt b/changes.txt index 8e1f81ac7e..4c83343090 100644 --- a/changes.txt +++ b/changes.txt @@ -1,12 +1,10 @@ CHANGES 2015-05-11 +- Release 2.0.0 - 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 @@ -18,22 +16,22 @@ 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 -- 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 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" } } } diff --git a/lib/Elastica/Util.php b/lib/Elastica/Util.php index 591a38d12d..74330ef69f 100644 --- a/lib/Elastica/Util.php +++ b/lib/Elastica/Util.php @@ -186,40 +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); - $search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_SCAN); - $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()); - } - } }