Skip to content

Commit 89d5c9d

Browse files
committed
indices cannot be deleted by aliases, only concrete index name
1 parent a070dda commit 89d5c9d

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ All notable changes to this project will be documented in this file based on the
1010
- removed analyzed/not_analyzed on [indices mapping](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/mapping-index.html)
1111
- [store](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/mapping-store.html) field only accepts boolean
1212
- Replace IndexAlreadyExistsException with [ResourceAlreadyExistsException](https://github.com/elastic/elasticsearch/pull/21494) [#1350](https://github.com/ruflin/Elastica/pull/1350)
13-
13+
- 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)
14+
1415
### Bugfixes
1516
- 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)
1617

test/Elastica/Index/SettingsTest.php

+30-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public function testGet()
3636
*/
3737
public function testGetWithAlias()
3838
{
39-
$this->markTestSkipped('ES6 update: to delete an index USE the concrete index name');
40-
4139
$indexName = 'elasticatest';
4240
$aliasName = 'elasticatest_alias';
4341

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

56+
$index = $client->getIndex($indexName);
5857
$index->delete();
5958
}
6059

60+
61+
/**
62+
* @group functional
63+
*
64+
*/
65+
public function testDeleteAliasWithException()
66+
{
67+
$indexName = 'deletetestaliasexception';
68+
$aliasName = 'deletetestaliasexception_alias';
69+
$client = $this->_getClient();
70+
$index = $client->getIndex($indexName);
71+
$index->create([], true);
72+
$index->refresh();
73+
74+
$index->addAlias($aliasName);
75+
76+
$indexAlias = $client->getIndex($aliasName);
77+
78+
try {
79+
$indexAlias->delete();
80+
$this->fail('Should throw exception because you should delete the concrete index and not the alias');
81+
} catch (ResponseException $e) {
82+
$error = $e->getResponse()->getFullError();
83+
84+
$this->assertContains('illegal_argument_exception', $error['type']);
85+
$this->assertContains('specify the corresponding concrete indices instead.', $error['reason']);
86+
}
87+
}
88+
6189
/**
6290
* @group functional
6391
*/

test/Elastica/Query/BoostingTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class BoostingTest extends BaseTest
1616
['name' => 'Vital Match', 'price' => 2.1],
1717
['name' => 'Mercury Vital', 'price' => 7.5],
1818
['name' => 'Fist Mercury', 'price' => 3.8],
19-
['name' => 'Lama Vital 2nd', 'price' => 1.2],
19+
['name' => 'Lama Vital 2nd', 'price' => 3.2],
2020
];
2121

2222
protected function _getTestIndex()

test/Elastica/Query/MoreLikeThisTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function testSearch()
2626

2727
$type = new Type($index, 'helloworldmlt');
2828
$mapping = new Mapping($type, [
29-
'email' => ['store' => 'true', 'type' => 'text', 'index' => 'true'],
30-
'content' => ['store' => 'true', 'type' => 'text', 'index' => 'true'],
29+
'email' => ['store' => true, 'type' => 'text', 'index' => true],
30+
'content' => ['store' => true, 'type' => 'text', 'index' => true],
3131
]);
3232

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

0 commit comments

Comments
 (0)