### Elasticsearch Version

"version": { "number": "7.16.2",     "build_flavor": "default",     "build_type": "docker",     "build_hash": "2b937c44140b6559905130a8650c64dbd0879cfb",     "build_date": "2021-12-18T19:42:46.604893745Z",     "build_snapshot": false,     "lucene_version": "8.10.1",     "minimum_wire_compatibility_version": "6.8.0",     "minimum_index_compatibility_version": "6.0.0-beta1"   }

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

http://docker.elastic.co/elasticsearch/elasticsearch:7.16.2

### Problem Description

We're encountering a NullPointerException when attempting to use the `_disk_usage` API [here](https://www.elastic.co/guide/en/elasticsearch/reference/7.16/indices-disk-usage.html).  This is a follow-up ticket creation to the discussion [here](https://discuss.elastic.co/t/unknown-response-error-when-running-using-disk-usage-api/307330/8).  Stack Trace provided below

### Steps to Reproduce

curl -H 'Content-type: application/json' -XPOST 'http://e2-es-http.default.svc.cluster.local:9200/ents_12_65_content_2/_disk_usage?run_expensive_tasks=true&pretty&error_trace'
-- output noted in "Logs" section below

We have extremely similar mappings / settings across environments / clusters / indices that potentially contains semi-sensitive information so it may take a bit to get redacted versions of those if needed.

### Logs (if relevant)

``` JSON
{
  "error": { 
    "root_cause": [ 
      { 
        "type": "illegal_state_exception",
        "reason": "unknown response [[ents_12_65_content_2/OtZ6u9v-Tvuhe23mn1gzMA][[ents_12_65_content_2][2]] BroadcastShardOperationFailedException[]; nested: RemoteTransportException[[e2-es-datanode-05-3][10.52.124.7:9300][indices:admin/analyze_disk_usage[s]]]; nested: NullPointerException[Cannot invoke \"org.apache.lucene.index.PointValues.getMinPackedValue()\" because \"values\" is null];]",
        "stack_trace": "[unknown response [[ents_12_65_content_2/OtZ6u9v-Tvuhe23mn1gzMA][[ents_12_65_content_2][2]] BroadcastShardOperationFailedException[]; nested: RemoteTransportException[[e2-es-datanode-05-3][10.52.124.7:9300][indices:admin/analyze_disk_usage[s]]]; nested: NullPointerException[Cannot invoke \"org.apache.lucene.index.PointValues.getMinPackedValue()\" because \"values\" is null];]]; nested: IllegalStateException[unknown response [[ents_12_65_content_2/OtZ6u9v-Tvuhe23mn1gzMA][[ents_12_65_content_2][2]] BroadcastShardOperationFailedException[]; nested: RemoteTransportException[[e2-es-datanode-05-3][10.52.124.7:9300][indices:admin/analyze_disk_usage[s]]]; nested: NullPointerException[Cannot invoke \"org.apache.lucene.index.PointValues.getMinPackedValue()\" because \"values\" is null];]];\n\tat org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:639)\n\tat org.elasticsearch.ElasticsearchException.generateFailureXContent(ElasticsearchException.java:567)\n\tat org.elasticsearch.rest.BytesRestResponse.build(BytesRestResponse.java:140)\n\tat org.elasticsearch.rest.BytesRestResponse.<init>(BytesRestResponse.java:101)\n\tat org.elasticsearch.rest.BytesRestResponse.<init>(BytesRestResponse.java:81)\n\tat org.elasticsearch.rest.action.RestActionListener.onFailure(RestActionListener.java:55)\n\tat org.elasticsearch.rest.action.RestCancellableNodeClient$1.onFailure(RestCancellableNodeClient.java:96)\n\tat org.elasticsearch.action.support.TransportAction$1.onFailure(TransportAction.java:97)\n\tat org.elasticsearch.action.support.ContextPreservingActionListener.onFailure(ContextPreservingActionListener.java:38)\n\tat org.elasticsearch.action.ActionListener$Delegating.onFailure(ActionListener.java:66)\n\tat org.elasticsearch.action.support.broadcast.TransportBroadcastAction$AsyncBroadcastAction.finishHim(TransportBroadcastAction.java:260)\n\tat org.elasticsearch.action.support.broadcast.TransportBroadcastAction$AsyncBroadcastAction.onOperation(TransportBroadcastAction.java:247)\n\tat org.elasticsearch.action.support.broadcast.TransportBroadcastAction$AsyncBroadcastAction$1.handleException(TransportBroadcastAction.java:191)\n\tat org.elasticsearch.transport.TransportService$4.handleException(TransportService.java:853)\n\tat org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1481)\n\tat org.elasticsearch.transport.InboundHandler.lambda$handleException$3(InboundHandler.java:368)\n\tat org.elasticsearch.common.util.concurrent.EsExecutors$DirectExecutorService.execute(EsExecutors.java:285)\n\tat org.elasticsearch.transport.InboundHandler.handleException(InboundHandler.java:366)\n\tat org.elasticsearch.transport.InboundHandler.handlerResponseError(InboundHandler.java:358)\n\tat org.elasticsearch.transport.InboundHandler.messageReceived(InboundHandler.java:132)\n\tat org.elasticsearch.transport.InboundHandler.inboundMessage(InboundHandler.java:88)\n\tat org.elasticsearch.transport.TcpTransport.inboundMessage(TcpTransport.java:743)\n\tat org.elasticsearch.transport.InboundPipeline.forwardFragments(InboundPipeline.java:147)\n\tat org.elasticsearch.transport.InboundPipeline.doHandleBytes(InboundPipeline.java:119)\n\tat org.elasticsearch.transport.InboundPipeline.handleBytes(InboundPipeline.java:84)\n\tat org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:71)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:280)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1374)\n\tat io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1237)\n\tat io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1286)\n\tat io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507)\n\tat io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:446)\n\tat io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:620)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:583)\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)\n\tat io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n\tat java.base/java.lang.Thread.run(Thread.java:833)\nCaused by: java.lang.IllegalStateException: unknown response [[ents_12_65_content_2/OtZ6u9v-Tvuhe23mn1gzMA][[ents_12_65_content_2][2]] BroadcastShardOperationFailedException[]; nested: RemoteTransportException[[e2-es-datanode-05-3][10.52.124.7:9300][indices:admin/analyze_disk_usage[s]]]; nested: NullPointerException[Cannot invoke \"org.apache.lucene.index.PointValues.getMinPackedValue()\" because \"values\" is null];]\n\tat org.elasticsearch.action.admin.indices.diskusage.TransportAnalyzeIndexDiskUsageAction.newResponse(TransportAnalyzeIndexDiskUsageAction.java:117)\n\tat org.elasticsearch.action.admin.indices.diskusage.TransportAnalyzeIndexDiskUsageAction.newResponse(TransportAnalyzeIndexDiskUsageAction.java:42)\n\tat org.elasticsearch.action.support.broadcast.TransportBroadcastAction$AsyncBroadcastAction.finishHim(TransportBroadcastAction.java:258)\n\t... 47 more\n"
      }
    ],
    "type": "illegal_state_exception",
    "reason": "unknown response [[ents_12_65_content_2/OtZ6u9v-Tvuhe23mn1gzMA][[ents_12_65_content_2][2]] BroadcastShardOperationFailedException[]; nested: RemoteTransportException[[e2-es-datanode-05-3][10.52.124.7:9300][indices:admin/analyze_disk_usage[s]]]; nested: NullPointerException[Cannot invoke \"org.apache.lucene.index.PointValues.getMinPackedValue()\" because \"values\" is null];]",
    "stack_trace": "java.lang.IllegalStateException: unknown response [[ents_12_65_content_2/OtZ6u9v-Tvuhe23mn1gzMA][[ents_12_65_content_2][2]] BroadcastShardOperationFailedException[]; nested: RemoteTransportException[[e2-es-datanode-05-3][10.52.124.7:9300][indices:admin/analyze_disk_usage[s]]]; nested: NullPointerException[Cannot invoke \"org.apache.lucene.index.PointValues.getMinPackedValue()\" because \"values\" is null];]\n\tat org.elasticsearch.action.admin.indices.diskusage.TransportAnalyzeIndexDiskUsageAction.newResponse(TransportAnalyzeIndexDiskUsageAction.java:117)\n\tat org.elasticsearch.action.admin.indices.diskusage.TransportAnalyzeIndexDiskUsageAction.newResponse(TransportAnalyzeIndexDiskUsageAction.java:42)\n\tat org.elasticsearch.action.support.broadcast.TransportBroadcastAction$AsyncBroadcastAction.finishHim(TransportBroadcastAction.java:258)\n\tat org.elasticsearch.action.support.broadcast.TransportBroadcastAction$AsyncBroadcastAction.onOperation(TransportBroadcastAction.java:247)\n\tat org.elasticsearch.action.support.broadcast.TransportBroadcastAction$AsyncBroadcastAction$1.handleException(TransportBroadcastAction.java:191)\n\tat org.elasticsearch.transport.TransportService$4.handleException(TransportService.java:853)\n\tat org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1481)\n\tat org.elasticsearch.transport.InboundHandler.lambda$handleException$3(InboundHandler.java:368)\n\tat org.elasticsearch.common.util.concurrent.EsExecutors$DirectExecutorService.execute(EsExecutors.java:285)\n\tat org.elasticsearch.transport.InboundHandler.handleException(InboundHandler.java:366)\n\tat org.elasticsearch.transport.InboundHandler.handlerResponseError(InboundHandler.java:358)\n\tat org.elasticsearch.transport.InboundHandler.messageReceived(InboundHandler.java:132)\n\tat org.elasticsearch.transport.InboundHandler.inboundMessage(InboundHandler.java:88)\n\tat org.elasticsearch.transport.TcpTransport.inboundMessage(TcpTransport.java:743)\n\tat org.elasticsearch.transport.InboundPipeline.forwardFragments(InboundPipeline.java:147)\n\tat org.elasticsearch.transport.InboundPipeline.doHandleBytes(InboundPipeline.java:119)\n\tat org.elasticsearch.transport.InboundPipeline.handleBytes(InboundPipeline.java:84)\n\tat org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:71)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:280)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1374)\n\tat io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1237)\n\tat io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1286)\n\tat io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507)\n\tat io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:446)\n\tat io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:620)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:583)\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)\n\tat io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n\tat java.base/java.lang.Thread.run(Thread.java:833)\n"
  },
  "status": 500
}
```
server/src/main/java/org/elasticsearch/action/admin/indices/diskusage/IndexDiskUsageAnalyzer.java
fieldLength += Integer.BYTES + bytesRef.length; 
                final int freq = (int) termsEnum.totalTermFreq();
                fieldLength += Integer.BYTES; 
                if (hasPositions || hasOffsets) {
                    docsAndPositions = termsEnum.postings(docsAndPositions, PostingsEnum.OFFSETS | PostingsEnum.PAYLOADS);
                    assert docsAndPositions != null;
                    while (docsAndPositions.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
                        cancellationChecker.logEvent();
                        assert docsAndPositions.freq() == freq;
                        for (int posUpTo = 0; posUpTo < freq; posUpTo++) {
                            final int pos = docsAndPositions.nextPosition();
                            fieldLength += Integer.BYTES; 
                            docsAndPositions.startOffset();
                            fieldLength += Integer.BYTES; 
                            docsAndPositions.endOffset();
                            fieldLength += Integer.BYTES; 
                            final BytesRef payload = docsAndPositions.getPayload();
                            if (payload != null) {
                                fieldLength += Integer.BYTES + payload.length; 
                            }
                            assert hasPositions == false || pos >= 0;
                        }
                    }
                }
            }
            final long finalLength = fieldLength;
            fields.compute(fieldName, (k, v) -> v == null ? finalLength : v + finalLength);
        }
    }
    private static class TrackingReadBytesDirectory extends FilterDirectory {