Skip to content

Commit 710582c

Browse files
authored
Merge pull request #177 from MITLibraries/add-shard-info
Index command returns shard info
2 parents f422a3e + 65cd471 commit 710582c

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

tests/test_opensearch.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ def test_get_formatted_indexes(test_opensearch_client):
125125
"\n Primary store size: 208b"
126126
"\n Total store size: 208b"
127127
"\n UUID: 60Gq-vaAScOKGXkG_JAw5A"
128+
"\n Primary Shards: 1"
129+
"\n Replica Shards: 1"
128130
"\n"
129131
"\nName: index-with-no-aliases"
130132
"\n Aliases: None"
@@ -134,6 +136,8 @@ def test_get_formatted_indexes(test_opensearch_client):
134136
"\n Primary store size: 208b"
135137
"\n Total store size: 208b"
136138
"\n UUID: KqVlOA5lTw-fXZA2TEqi_g"
139+
"\n Primary Shards: 1"
140+
"\n Replica Shards: 1"
137141
"\n"
138142
"\nName: index-with-one-alias"
139143
"\n Aliases: alias-with-multiple-indexes"
@@ -143,6 +147,8 @@ def test_get_formatted_indexes(test_opensearch_client):
143147
"\n Primary store size: 208b"
144148
"\n Total store size: 208b"
145149
"\n UUID: q-NKXPp3SuWiDKhPkUxP-g"
150+
"\n Primary Shards: 1"
151+
"\n Replica Shards: 1"
146152
"\n"
147153
)
148154

tim/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def indexes(ctx: click.Context) -> None:
9595
9696
Prints all indexes in the cluster in alphabetical order by name. For each index,
9797
displays information including its status, health, number of documents, primary
98-
store size, total store size, and UUID.
98+
store size, total store size, UUID, primary shard count, and replica shard count.
9999
"""
100100
click.echo(tim_os.get_formatted_indexes(ctx.obj["CLIENT"]))
101101

tim/opensearch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ def get_formatted_indexes(client: OpenSearch) -> str:
117117
f" Primary store size: {info['pri.store.size']}\n"
118118
f" Total store size: {info['store.size']}\n"
119119
f" UUID: {info['uuid']}\n"
120+
f" Primary Shards: {int(info['pri']):,}\n"
121+
f" Replica Shards: {int(info['rep']):,}\n"
120122
)
121123
return output
122124
return output + " No indexes present in OpenSearch cluster."

0 commit comments

Comments
 (0)