Skip to content

Commit

Permalink
indices cannot be deleted by aliases, only concrete index name
Browse files Browse the repository at this point in the history
  • Loading branch information
p365labs committed Aug 15, 2017
1 parent 00be0b8 commit c624639
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ All notable changes to this project will be documented in this file based on the

### Backward Compatibility Breaks

- Numeric to and from parameters in [date_range aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_aggregations_changes.html#_numeric_literal_to_literal_and_literal_from_literal_parameters_in_literal_date_range_literal_aggregation_are_interpreted_according_to_literal_format_literal_now) are interpreted according to format of the target field
- In ES6 only [strict type boolean](https://github.com/elastic/elasticsearch/pull/22200) are accepted. [On ES6 docs](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/boolean.html)
- 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
- Numeric to and from parameters in [date_range aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_aggregations_changes.html#_numeric_literal_to_literal_and_literal_from_literal_parameters_in_literal_date_range_literal_aggregation_are_interpreted_according_to_literal_format_literal_now) are interpreted according to format of the target field [#1346](https://github.com/ruflin/Elastica/pull/1346)
- In ES6 only [strict type boolean](https://github.com/elastic/elasticsearch/pull/22200) are accepted. [On ES6 docs](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/boolean.html) [#1347](https://github.com/ruflin/Elastica/pull/1347)
- removed analyzed/not_analyzed on [indices mapping](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/mapping-index.html) [#1319](https://github.com/ruflin/Elastica/pull/1319) [#1347](https://github.com/ruflin/Elastica/pull/1347)
- [store](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/mapping-store.html) field only accepts boolean [#1319](https://github.com/ruflin/Elastica/pull/1319) [#1347](https://github.com/ruflin/Elastica/pull/1347)
- 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

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

0 comments on commit c624639

Please sign in to comment.