How can i get the size of only primary shards?
using java api?
Hi @prasanna_kumar,
very quick and dirty but should get you started:
long totalSizeInBytes = 0;
for (Map.Entry<String, IndexStats> indexStats : client().admin().indices().prepareStats().get().getIndices().entrySet()) {
totalSizeInBytes += indexStats.getValue().getPrimaries().getStore().getSize().bytes();
}
System.out.printf("total size is %d bytes.%n", totalSizeInBytes);
Also: you do not specify what you mean by "size". I assumed you meant size in bytes.
Daniel
Thank you @danielmitterdorfer it helped.
IndicesStatsResponse response = client.admin().indices().prepareStats(indexName).clear()
.setStore(true).execute().actionGet();
ByteSizeValue bsv2 = response.getIndex(indexName).getPrimaries().getStore().getSize();