From 07a82d0c098c16608990fbac67c191d66d0027a3 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 13 Jan 2016 12:46:18 +0100 Subject: [PATCH] make get alias expand to open and closed indices by default This change affects get alias, get aliases as well as cat aliases. They all return closed indices too by default. get alias and get aliases also allow to return open indices only through the `expand_wildcards` option (set it to `open`). Closes #14982 --- .../indices/alias/get/GetAliasesRequest.java | 2 +- .../test/cat.aliases/10_basic.yaml | 28 +++++++++++++++++++ .../test/indices.get_alias/10_basic.yaml | 22 +++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java b/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java index 182b86fd149..fd3a93b69d9 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java @@ -35,7 +35,7 @@ public class GetAliasesRequest extends MasterNodeReadRequest private String[] indices = Strings.EMPTY_ARRAY; private String[] aliases = Strings.EMPTY_ARRAY; - private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen(); + private IndicesOptions indicesOptions = IndicesOptions.strictExpand(); public GetAliasesRequest(String[] aliases) { this.aliases = aliases; diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yaml index 3ee33b0a67b..deb1307cec8 100755 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yaml @@ -188,3 +188,31 @@ index \s+ alias \n test \s+ test_1 \n $/ + +--- +"Alias against closed index": + + - do: + indices.create: + index: test_index + body: + aliases: + test_alias: {} + + - do: + indices.close: + index: test_index + + - do: + cat.aliases: {} + + - match: + $body: | + /^ + test_alias \s+ + test_index \s+ + - \s+ + - \s+ + - \s+ + $/ + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_alias/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_alias/10_basic.yaml index 22a67a99144..3cbac46aa59 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_alias/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_alias/10_basic.yaml @@ -205,3 +205,25 @@ setup: - is_true: test_index - is_true: test_index_2 + +--- +"Get alias against closed indices": + + - do: + indices.close: + index: test_index_2 + + - do: + indices.get_alias: + name: test_alias + + - is_true: test_index + - is_true: test_index_2 + + - do: + indices.get_alias: + name: test_alias + expand_wildcards: open + + - is_true: test_index + - is_false: test_index_2