Revert change that does not return all indices if a specific alias is requested via get alias api. (#28294)
Reopens #27763
This commit is contained in:
parent
ef5c041819
commit
4ef341a0c3
|
@ -276,11 +276,8 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, To
|
||||||
if (!filteredValues.isEmpty()) {
|
if (!filteredValues.isEmpty()) {
|
||||||
// Make the list order deterministic
|
// Make the list order deterministic
|
||||||
CollectionUtil.timSort(filteredValues, Comparator.comparing(AliasMetaData::alias));
|
CollectionUtil.timSort(filteredValues, Comparator.comparing(AliasMetaData::alias));
|
||||||
mapBuilder.put(index, Collections.unmodifiableList(filteredValues));
|
|
||||||
} else if (matchAllAliases) {
|
|
||||||
// in case all aliases are requested then it is desired to return the concrete index with no aliases (#25114):
|
|
||||||
mapBuilder.put(index, Collections.emptyList());
|
|
||||||
}
|
}
|
||||||
|
mapBuilder.put(index, Collections.unmodifiableList(filteredValues));
|
||||||
}
|
}
|
||||||
return mapBuilder.build();
|
return mapBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -570,20 +570,24 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
logger.info("--> getting alias1");
|
logger.info("--> getting alias1");
|
||||||
GetAliasesResponse getResponse = admin().indices().prepareGetAliases("alias1").get();
|
GetAliasesResponse getResponse = admin().indices().prepareGetAliases("alias1").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(5));
|
||||||
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(1));
|
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(1));
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).alias(), equalTo("alias1"));
|
assertThat(getResponse.getAliases().get("foobar").get(0).alias(), equalTo("alias1"));
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
||||||
|
assertTrue(getResponse.getAliases().get("test").isEmpty());
|
||||||
|
assertTrue(getResponse.getAliases().get("test123").isEmpty());
|
||||||
|
assertTrue(getResponse.getAliases().get("foobarbaz").isEmpty());
|
||||||
|
assertTrue(getResponse.getAliases().get("bazbar").isEmpty());
|
||||||
AliasesExistResponse existsResponse = admin().indices().prepareAliasesExist("alias1").get();
|
AliasesExistResponse existsResponse = admin().indices().prepareAliasesExist("alias1").get();
|
||||||
assertThat(existsResponse.exists(), equalTo(true));
|
assertThat(existsResponse.exists(), equalTo(true));
|
||||||
|
|
||||||
logger.info("--> getting all aliases that start with alias*");
|
logger.info("--> getting all aliases that start with alias*");
|
||||||
getResponse = admin().indices().prepareGetAliases("alias*").get();
|
getResponse = admin().indices().prepareGetAliases("alias*").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(5));
|
||||||
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(2));
|
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(2));
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).alias(), equalTo("alias1"));
|
assertThat(getResponse.getAliases().get("foobar").get(0).alias(), equalTo("alias1"));
|
||||||
|
@ -595,6 +599,10 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(1).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(1).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(1).getIndexRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(1).getIndexRouting(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(1).getSearchRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(1).getSearchRouting(), nullValue());
|
||||||
|
assertTrue(getResponse.getAliases().get("test").isEmpty());
|
||||||
|
assertTrue(getResponse.getAliases().get("test123").isEmpty());
|
||||||
|
assertTrue(getResponse.getAliases().get("foobarbaz").isEmpty());
|
||||||
|
assertTrue(getResponse.getAliases().get("bazbar").isEmpty());
|
||||||
existsResponse = admin().indices().prepareAliasesExist("alias*").get();
|
existsResponse = admin().indices().prepareAliasesExist("alias*").get();
|
||||||
assertThat(existsResponse.exists(), equalTo(true));
|
assertThat(existsResponse.exists(), equalTo(true));
|
||||||
|
|
||||||
|
@ -679,12 +687,13 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
logger.info("--> getting f* for index *bar");
|
logger.info("--> getting f* for index *bar");
|
||||||
getResponse = admin().indices().prepareGetAliases("f*").addIndices("*bar").get();
|
getResponse = admin().indices().prepareGetAliases("f*").addIndices("*bar").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(2));
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).alias(), equalTo("foo"));
|
assertThat(getResponse.getAliases().get("foobar").get(0).alias(), equalTo("foo"));
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
||||||
|
assertTrue(getResponse.getAliases().get("bazbar").isEmpty());
|
||||||
existsResponse = admin().indices().prepareAliasesExist("f*")
|
existsResponse = admin().indices().prepareAliasesExist("f*")
|
||||||
.addIndices("*bar").get();
|
.addIndices("*bar").get();
|
||||||
assertThat(existsResponse.exists(), equalTo(true));
|
assertThat(existsResponse.exists(), equalTo(true));
|
||||||
|
@ -693,13 +702,14 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
||||||
logger.info("--> getting f* for index *bac");
|
logger.info("--> getting f* for index *bac");
|
||||||
getResponse = admin().indices().prepareGetAliases("foo").addIndices("*bac").get();
|
getResponse = admin().indices().prepareGetAliases("foo").addIndices("*bac").get();
|
||||||
assertThat(getResponse, notNullValue());
|
assertThat(getResponse, notNullValue());
|
||||||
assertThat(getResponse.getAliases().size(), equalTo(1));
|
assertThat(getResponse.getAliases().size(), equalTo(2));
|
||||||
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(1));
|
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(1));
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).alias(), equalTo("foo"));
|
assertThat(getResponse.getAliases().get("foobar").get(0).alias(), equalTo("foo"));
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
|
||||||
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
|
||||||
|
assertTrue(getResponse.getAliases().get("bazbar").isEmpty());
|
||||||
existsResponse = admin().indices().prepareAliasesExist("foo")
|
existsResponse = admin().indices().prepareAliasesExist("foo")
|
||||||
.addIndices("*bac").get();
|
.addIndices("*bac").get();
|
||||||
assertThat(existsResponse.exists(), equalTo(true));
|
assertThat(existsResponse.exists(), equalTo(true));
|
||||||
|
|
Loading…
Reference in New Issue