From 3339dc9ce3b7b238350857f46ba63785a2a20fbe Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Tue, 23 Jul 2019 12:24:22 -0700 Subject: [PATCH 1/6] Add is_write_index column to cat.aliases Aliases have had the option to set `is_write_index` since 6.4, but the cat.aliases action was never updated. --- .../rest-api-spec/test/cat.aliases/10_basic.yml | 9 ++++++++- .../elasticsearch/rest/action/cat/RestAliasAction.java | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) 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 bdcee7af1bcb6..8745cc79ced81 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 @@ -11,6 +11,7 @@ filter .+ \n routing.index .+ \n routing.search .+ \n + is_write_index .+ \n $/ --- @@ -47,6 +48,7 @@ - \s+ - \s+ - \s+ + - \s+ $/ --- @@ -68,6 +70,7 @@ body: index_routing: ir search_routing: "sr1,sr2" + is_write_index: true filter: term: foo: bar @@ -82,6 +85,7 @@ [*] \s+ ir \s+ sr1,sr2 \s+ + true \s+ $/ --- @@ -189,13 +193,15 @@ 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+ $/ @@ -255,6 +261,7 @@ - \s+ - \s+ - \s+ + - \s+ $/ --- 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 774a603cb4b7f..79d9a3a7c9475 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 @@ -79,6 +79,7 @@ protected Table getTableWithHeader(RestRequest request) { 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; } @@ -97,6 +98,8 @@ private Table buildTable(RestRequest request, GetAliasesResponse response) { 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(); } } From 922ed094c117ff261bc0c6b6cc0efca1e4916724 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Thu, 1 Aug 2019 18:04:26 -0700 Subject: [PATCH 2/6] Fix doc test --- docs/reference/cat/alias.asciidoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/reference/cat/alias.asciidoc b/docs/reference/cat/alias.asciidoc index 4fef1a85f9678..a6824f4238db9 100644 --- a/docs/reference/cat/alias.asciidoc +++ b/docs/reference/cat/alias.asciidoc @@ -43,11 +43,11 @@ Might respond with: [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] From 71b13ca3b8bf40b6295b1c48a0fda89c99195cf2 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Mon, 5 Aug 2019 13:17:25 -0700 Subject: [PATCH 3/6] bwc fix --- .../test/cat.aliases/10_basic.yml | 170 +++++++++++++++++- 1 file changed, 168 insertions(+), 2 deletions(-) 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 8745cc79ced81..9b67672d8d04f 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,5 +1,30 @@ + --- "Help": + - skip: + version: " - 7.99.99" + reason: "is_write_index is shown in the cat.aliases starting version 8.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 8.0)": + - skip: + version: "8.0.0 - " + reason: "is_write_index is shown in the cat cat.aliases starting version 8.0" + - do: cat.aliases: help: true @@ -11,7 +36,6 @@ filter .+ \n routing.index .+ \n routing.search .+ \n - is_write_index .+ \n $/ --- @@ -27,6 +51,9 @@ --- "Simple alias": + - skip: + version: " - 7.99.99" + reason: "is_write_index is shown in the cat.aliases starting version 8.0" - do: indices.create: @@ -51,8 +78,39 @@ - \s+ $/ +--- +"Simple alias (pre 8.0)": + - skip: + version: "8.0.0 - " + reason: "is_write_index is shown in the cat cat.aliases starting version 8.0" + + - do: + indices.create: + index: test + + - do: + indices.put_alias: + index: test + name: test_alias + + - do: + cat.aliases: {} + + - match: + $body: | + /^ + test_alias \s+ + test \s+ + - \s+ + - \s+ + - \s+ + $/ + --- "Complex alias": + - skip: + version: " - 7.99.99" + reason: "is_write_index is shown in the cat.aliases starting version 8.0" - do: indices.create: @@ -88,6 +146,44 @@ true \s+ $/ +--- +"Complex alias (pre 8.0)": + - skip: + version: "8.0.0 - " + reason: "is_write_index is shown in the cat cat.aliases starting version 8.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: + cat.aliases: {} + + - match: + $body: | + /^ + test_alias \s+ + test \s+ + [*] \s+ + ir \s+ + sr1,sr2 \s+ + $/ + --- "Alias name": @@ -173,6 +269,9 @@ --- "Column headers": + - skip: + version: " - 7.99.99" + reason: "is_write_index is shown in the cat.aliases starting version 8.0" - do: indices.create: @@ -201,9 +300,43 @@ - \s+ - \s+ - \s+ - - \s+ + - \s+ $/ +--- +"Column headers (pre 8.0)": + - skip: + version: "8.0.0 - " + reason: "is_write_index is shown in the cat cat.aliases starting version 8.0" + + - do: + indices.create: + index: test + + - do: + indices.put_alias: + index: test + name: test_1 + + - do: + cat.aliases: + v: true + + - match: + $body: | + /^ alias \s+ + index \s+ + filter \s+ + routing.index \s+ + routing.search \s+ + is_write_index + \n + test_1 \s+ + test \s+ + - \s+ + - \s+ + - \s+ + $/ --- "Select columns": @@ -238,6 +371,9 @@ --- "Alias against closed index": + - skip: + version: " - 7.99.99" + reason: "is_write_index is shown in the cat.aliases starting version 8.0" - do: indices.create: @@ -264,6 +400,36 @@ - \s+ $/ +--- +"Alias against closed index (pre 8.0)": + - skip: + version: "8.0.0 - " + reason: "is_write_index is shown in the cat cat.aliases starting version 8.0" + + - 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+ + $/ + --- "Alias sorting": From 4d916ed06c11751aa7207891f9bebc4b8767818e Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Mon, 5 Aug 2019 13:49:46 -0700 Subject: [PATCH 4/6] fix typo --- .../test/cat.aliases/10_basic.yml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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 9b67672d8d04f..e38fde096d112 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 @@ -3,7 +3,7 @@ "Help": - skip: version: " - 7.99.99" - reason: "is_write_index is shown in the cat.aliases starting version 8.0" + reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: cat.aliases: @@ -23,7 +23,7 @@ "Help (pre 8.0)": - skip: version: "8.0.0 - " - reason: "is_write_index is shown in the cat cat.aliases starting version 8.0" + reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: cat.aliases: @@ -53,7 +53,7 @@ "Simple alias": - skip: version: " - 7.99.99" - reason: "is_write_index is shown in the cat.aliases starting version 8.0" + reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: indices.create: @@ -82,7 +82,7 @@ "Simple alias (pre 8.0)": - skip: version: "8.0.0 - " - reason: "is_write_index is shown in the cat cat.aliases starting version 8.0" + reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: indices.create: @@ -110,7 +110,7 @@ "Complex alias": - skip: version: " - 7.99.99" - reason: "is_write_index is shown in the cat.aliases starting version 8.0" + reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: indices.create: @@ -150,7 +150,7 @@ "Complex alias (pre 8.0)": - skip: version: "8.0.0 - " - reason: "is_write_index is shown in the cat cat.aliases starting version 8.0" + reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: indices.create: @@ -271,7 +271,7 @@ "Column headers": - skip: version: " - 7.99.99" - reason: "is_write_index is shown in the cat.aliases starting version 8.0" + reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: indices.create: @@ -307,7 +307,7 @@ "Column headers (pre 8.0)": - skip: version: "8.0.0 - " - reason: "is_write_index is shown in the cat cat.aliases starting version 8.0" + reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: indices.create: @@ -373,7 +373,7 @@ "Alias against closed index": - skip: version: " - 7.99.99" - reason: "is_write_index is shown in the cat.aliases starting version 8.0" + reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: indices.create: @@ -404,7 +404,7 @@ "Alias against closed index (pre 8.0)": - skip: version: "8.0.0 - " - reason: "is_write_index is shown in the cat cat.aliases starting version 8.0" + reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: indices.create: From 683640331c4ce4e6b27e2fe20e062e6cfe9979ab Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Tue, 20 Aug 2019 16:14:43 -0700 Subject: [PATCH 5/6] fix test bug --- .../main/resources/rest-api-spec/test/cat.aliases/10_basic.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 e38fde096d112..4aa99b09d38b8 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 @@ -328,8 +328,7 @@ index \s+ filter \s+ routing.index \s+ - routing.search \s+ - is_write_index + routing.search \n test_1 \s+ test \s+ From 46ee89831634c76489a6ba957e85ae4d8872e849 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Tue, 20 Aug 2019 19:08:50 -0700 Subject: [PATCH 6/6] use node_selector --- .../rest-api-spec/test/cat.aliases/10_basic.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 4aa99b09d38b8..bb96c5d24f376 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 @@ -23,9 +23,12 @@ "Help (pre 8.0)": - skip: version: "8.0.0 - " + features: node_selector reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: + node_selector: + version: " - 7.99.99" cat.aliases: help: true @@ -82,6 +85,7 @@ "Simple alias (pre 8.0)": - skip: version: "8.0.0 - " + features: node_selector reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: @@ -94,6 +98,8 @@ name: test_alias - do: + node_selector: + version: " - 7.99.99" cat.aliases: {} - match: @@ -150,6 +156,7 @@ "Complex alias (pre 8.0)": - skip: version: "8.0.0 - " + features: node_selector reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: @@ -172,6 +179,8 @@ term: foo: bar - do: + node_selector: + version: " - 7.99.99" cat.aliases: {} - match: @@ -307,6 +316,7 @@ "Column headers (pre 8.0)": - skip: version: "8.0.0 - " + features: node_selector reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: @@ -319,6 +329,8 @@ name: test_1 - do: + node_selector: + version: " - 7.99.99" cat.aliases: v: true @@ -403,6 +415,7 @@ "Alias against closed index (pre 8.0)": - skip: version: "8.0.0 - " + features: node_selector reason: "is_write_index is shown in cat.aliases starting version 8.0" - do: @@ -417,6 +430,8 @@ index: test_index - do: + node_selector: + version: " - 7.99.99" cat.aliases: {} - match: