Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete indices only by concrete name #1348

Merged
merged 1 commit into from
Aug 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ All notable changes to this project will be documented in this file based on the
- removed analyzed/not_analyzed on [indices mapping](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/mapping-index.html)
- [store](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/mapping-store.html) field only accepts boolean
- Replace IndexAlreadyExistsException with [ResourceAlreadyExistsException](https://github.com/elastic/elasticsearch/pull/21494) [#1350](https://github.com/ruflin/Elastica/pull/1350)

- in order to delete an index you should not delete by its alias now you should delete using the [concrete index name](https://github.com/elastic/elasticsearch/blob/6.0/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java#L445) [#1348](https://github.com/ruflin/Elastica/pull/1348)

### Bugfixes
- Enforce [Content-Type requirement on the layer Rest](https://github.com/elastic/elasticsearch/pull/23146), a [PR on Elastica #1301](https://github.com/ruflin/Elastica/issues/1301) solved it (it has been implemented only in the HTTP Transport), but it was not implemented in the Guzzle Transport. [#1349](https://github.com/ruflin/Elastica/pull/1349)

Expand Down
32 changes: 30 additions & 2 deletions test/Elastica/Index/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public function testGet()
*/
public function testGetWithAlias()
{
$this->markTestSkipped('ES6 update: to delete an index USE the concrete index name');

$indexName = 'elasticatest';
$aliasName = 'elasticatest_alias';

Expand All @@ -55,9 +53,39 @@ public function testGetWithAlias()
$this->assertNotNull($settings->get('number_of_shards'));
$this->assertNull($settings->get('kjqwerjlqwer'));

$index = $client->getIndex($indexName);
$index->delete();
}


/**
* @group functional
*
*/
public function testDeleteAliasWithException()
{
$indexName = 'deletetestaliasexception';
$aliasName = 'deletetestaliasexception_alias';
$client = $this->_getClient();
$index = $client->getIndex($indexName);
$index->create([], true);
$index->refresh();

$index->addAlias($aliasName);

$indexAlias = $client->getIndex($aliasName);

try {
$indexAlias->delete();
$this->fail('Should throw exception because you should delete the concrete index and not the alias');
} catch (ResponseException $e) {
$error = $e->getResponse()->getFullError();

$this->assertContains('illegal_argument_exception', $error['type']);
$this->assertContains('specify the corresponding concrete indices instead.', $error['reason']);
}
}

/**
* @group functional
*/
Expand Down
2 changes: 1 addition & 1 deletion test/Elastica/Query/BoostingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BoostingTest extends BaseTest
['name' => 'Vital Match', 'price' => 2.1],
['name' => 'Mercury Vital', 'price' => 7.5],
['name' => 'Fist Mercury', 'price' => 3.8],
['name' => 'Lama Vital 2nd', 'price' => 1.2],
['name' => 'Lama Vital 2nd', 'price' => 3.2],
];

protected function _getTestIndex()
Expand Down
4 changes: 2 additions & 2 deletions test/Elastica/Query/MoreLikeThisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function testSearch()

$type = new Type($index, 'helloworldmlt');
$mapping = new Mapping($type, [
'email' => ['store' => 'true', 'type' => 'text', 'index' => 'true'],
'content' => ['store' => 'true', 'type' => 'text', 'index' => 'true'],
'email' => ['store' => true, 'type' => 'text', 'index' => true],
'content' => ['store' => true, 'type' => 'text', 'index' => true],
]);

$mapping->setSource(['enabled' => false]);
Expand Down