Skip to content

Commit

Permalink
Merge pull request #839 from ruflin/release-2.0.0
Browse files Browse the repository at this point in the history
Release 2.0.0
  • Loading branch information
ruflin committed May 13, 2015
2 parents 96e87c8 + d4fa023 commit dfe06cc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 115 deletions.
20 changes: 9 additions & 11 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
"dev-master": "2.0.x-dev"
}
}
}
36 changes: 0 additions & 36 deletions lib/Elastica/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
67 changes: 0 additions & 67 deletions test/lib/Elastica/Test/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

0 comments on commit dfe06cc

Please sign in to comment.