Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add is_write_index column to cat.aliases #44772

Merged
merged 10 commits into from
Aug 21, 2019
10 changes: 5 additions & 5 deletions docs/reference/cat/alias.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@

---
"Help":
- skip:
version: " - 7.99.99"
reason: "is_write_index is shown in 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 - "
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

Expand All @@ -26,6 +54,9 @@

---
"Simple alias":
- skip:
version: " - 7.99.99"
reason: "is_write_index is shown in cat.aliases starting version 8.0"

- do:
indices.create:
Expand All @@ -47,10 +78,45 @@
- \s+
- \s+
- \s+
- \s+
$/

---
"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:
indices.create:
index: test

- do:
indices.put_alias:
index: test
name: test_alias

- do:
node_selector:
version: " - 7.99.99"
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 cat.aliases starting version 8.0"

- do:
indices.create:
Expand All @@ -68,6 +134,7 @@
body:
index_routing: ir
search_routing: "sr1,sr2"
is_write_index: true
filter:
term:
foo: bar
Expand All @@ -82,8 +149,50 @@
[*] \s+
ir \s+
sr1,sr2 \s+
true \s+
$/

---
"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:
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.99.99"
cat.aliases: {}

- match:
$body: |
/^
test_alias \s+
test \s+
[*] \s+
ir \s+
sr1,sr2 \s+
$/

---
"Alias name":

Expand Down Expand Up @@ -169,6 +278,9 @@

---
"Column headers":
- skip:
version: " - 7.99.99"
reason: "is_write_index is shown in cat.aliases starting version 8.0"

- do:
indices.create:
Expand All @@ -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 8.0)":
- skip:
version: "8.0.0 - "
features: node_selector
reason: "is_write_index is shown in cat.aliases starting version 8.0"

- do:
indices.create:
index: test

- do:
indices.put_alias:
index: test
name: test_1

- do:
node_selector:
version: " - 7.99.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":
Expand Down Expand Up @@ -232,6 +382,9 @@

---
"Alias against closed index":
- skip:
version: " - 7.99.99"
reason: "is_write_index is shown in cat.aliases starting version 8.0"

- do:
indices.create:
Expand All @@ -255,8 +408,42 @@
- \s+
- \s+
- \s+
- \s+
$/

---
"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:
indices.create:
index: test_index
body:
aliases:
test_alias: {}

- do:
indices.close:
index: test_index

- do:
node_selector:
version: " - 7.99.99"
cat.aliases: {}

- match:
$body: |
/^
test_alias \s+
test_index \s+
- \s+
- \s+
- \s+
$/

---
"Alias sorting":

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,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;
}
Expand All @@ -95,6 +96,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();
}
}
Expand Down