diff --git a/docs/reference/cat/alias.asciidoc b/docs/reference/cat/alias.asciidoc index 619374504c0..dc385a91e03 100644 --- a/docs/reference/cat/alias.asciidoc +++ b/docs/reference/cat/alias.asciidoc @@ -79,11 +79,11 @@ The API returns the following response: [source,txt] -------------------------------------------------- -alias index filter routing.index routing.search -alias1 test1 - - - -alias2 test1 * - - -alias3 test1 - 1 1 -alias4 test1 - 2 1,2 +alias index filter routing.index routing.search is_write_index +alias1 test1 - - - - +alias2 test1 * - - - +alias3 test1 - 1 1 - +alias4 test1 - 2 1,2 - -------------------------------------------------- // TESTRESPONSE[s/[*]/[*]/ non_json] diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yml index bdcee7af1bc..5669206ee87 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yml @@ -1,9 +1,37 @@ + --- "Help": + - skip: + version: " - 7.3.99" + reason: "is_write_index is shown in cat.aliases starting version 7.4.0" + - do: cat.aliases: help: true + - match: + $body: | + /^ alias .+ \n + index .+ \n + filter .+ \n + routing.index .+ \n + routing.search .+ \n + is_write_index .+ \n + $/ + +--- +"Help (pre 7.4.0)": + - skip: + version: "7.4.0 - " + features: node_selector + reason: "is_write_index is shown in cat.aliases starting version 7.4.0" + + - do: + node_selector: + version: " - 7.3.99" + cat.aliases: + help: true + - match: $body: | /^ alias .+ \n @@ -26,6 +54,9 @@ --- "Simple alias": + - skip: + version: " - 7.3.99" + reason: "is_write_index is shown in cat.aliases starting version 7.4.0" - do: indices.create: @@ -47,10 +78,45 @@ - \s+ - \s+ - \s+ + - \s+ $/ +--- +"Simple alias (pre 7.4.0)": + - skip: + version: "7.4.0 - " + features: node_selector + reason: "is_write_index is shown in cat.aliases starting version 7.4.0" + + - do: + indices.create: + index: test + + - do: + indices.put_alias: + index: test + name: test_alias + + - do: + node_selector: + version: " - 7.3.99" + cat.aliases: {} + + - match: + $body: | + /^ + test_alias \s+ + test \s+ + - \s+ + - \s+ + - \s+ + $/ + --- "Complex alias": + - skip: + version: " - 7.3.99" + reason: "is_write_index is shown in cat.aliases starting version 7.4.0" - do: indices.create: @@ -68,6 +134,7 @@ body: index_routing: ir search_routing: "sr1,sr2" + is_write_index: true filter: term: foo: bar @@ -82,8 +149,50 @@ [*] \s+ ir \s+ sr1,sr2 \s+ + true \s+ $/ +--- +"Complex alias (pre 7.4.0)": + - skip: + version: "7.4.0 - " + features: node_selector + reason: "is_write_index is shown in cat.aliases starting version 7.4.0" + + - do: + indices.create: + index: test + body: + mappings: + properties: + foo: + type: text + + - do: + indices.put_alias: + index: test + name: test_alias + body: + index_routing: ir + search_routing: "sr1,sr2" + filter: + term: + foo: bar + - do: + node_selector: + version: " - 7.3.99" + cat.aliases: {} + + - match: + $body: | + /^ + test_alias \s+ + test \s+ + [*] \s+ + ir \s+ + sr1,sr2 \s+ + $/ + --- "Alias name": @@ -169,6 +278,9 @@ --- "Column headers": + - skip: + version: " - 7.3.99" + reason: "is_write_index is shown in cat.aliases starting version 7.4.0" - do: indices.create: @@ -189,15 +301,53 @@ index \s+ filter \s+ routing.index \s+ - routing.search + routing.search \s+ + is_write_index \n test_1 \s+ test \s+ - \s+ - \s+ - \s+ + - \s+ $/ +--- +"Column headers (pre 7.4.0)": + - skip: + version: "7.4.0 - " + features: node_selector + reason: "is_write_index is shown in cat.aliases starting version 7.4.0" + + - do: + indices.create: + index: test + + - do: + indices.put_alias: + index: test + name: test_1 + + - do: + node_selector: + version: " - 7.3.99" + cat.aliases: + v: true + + - match: + $body: | + /^ alias \s+ + index \s+ + filter \s+ + routing.index \s+ + routing.search + \n + test_1 \s+ + test \s+ + - \s+ + - \s+ + - \s+ + $/ --- "Select columns": @@ -232,6 +382,9 @@ --- "Alias against closed index": + - skip: + version: " - 7.3.99" + reason: "is_write_index is shown in cat.aliases starting version 7.4.0" - do: indices.create: @@ -255,8 +408,42 @@ - \s+ - \s+ - \s+ + - \s+ $/ +--- +"Alias against closed index (pre 7.4.0)": + - skip: + version: "7.4.0 - " + features: node_selector + reason: "is_write_index is shown in cat.aliases starting version 7.4.0" + + - do: + indices.create: + index: test_index + body: + aliases: + test_alias: {} + + - do: + indices.close: + index: test_index + + - do: + node_selector: + version: " - 7.3.99" + cat.aliases: {} + + - match: + $body: | + /^ + test_alias \s+ + test_index \s+ + - \s+ + - \s+ + - \s+ + $/ + --- "Alias sorting": diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java index b46ad80e338..4fd43becf43 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java @@ -77,6 +77,7 @@ public class RestAliasAction extends AbstractCatAction { table.addCell("filter", "alias:f,fi;desc:filter"); table.addCell("routing.index", "alias:ri,routingIndex;desc:index routing"); table.addCell("routing.search", "alias:rs,routingSearch;desc:search routing"); + table.addCell("is_write_index", "alias:w,isWriteIndex;desc:write index"); table.endHeaders(); return table; } @@ -95,6 +96,8 @@ public class RestAliasAction extends AbstractCatAction { table.addCell(indexRouting); String searchRouting = Strings.hasLength(aliasMetaData.searchRouting()) ? aliasMetaData.searchRouting() : "-"; table.addCell(searchRouting); + String isWriteIndex = aliasMetaData.writeIndex() == null ? "-" : aliasMetaData.writeIndex().toString(); + table.addCell(isWriteIndex); table.endRow(); } }