@Override
protected CacheStatsPerFieldStats nodeOperation(CacheStatsPerFieldStatsRequest nodeStatsRequest) throws ElasticSearchException {
List<CacheStatsPerFieldStats.FieldEntry> entries = Lists.newArrayList();
for (IndexService indexService : indicesService) {
logger.debug("Starting to analyze index {}",indexService.settingsService().index().name());
FieldDataCache fieldData = indexService.cache().fieldData();
for (DocumentMapper mapper : indexService.mapperService()) {
for (FieldMapper fieldMapper : mapper.mappers()) {
String field = fieldMapper.names().indexName();
logger.debug("Calculating size for field {}",field);
long size = fieldData.sizeInBytes(field);
if (size > 0) {
logger.debug("Size for field {}: {}",field,size);
entries.add(new CacheStatsPerFieldStats.FieldEntry(field,size));
}
else logger.debug("Field {} is has no cache. Skipping.",field);