private void getStoredData(final IndexField[] storedFields,
                               final Set<String> fieldsToLoad,
                               final ValuesConsumer valuesConsumer,
                               final IndexSearcher searcher,
                               final int docId,
                               final ErrorConsumer errorConsumer) {
        try {
            SearchProgressLog.increment(queryKey, SearchPhase.INDEX_SHARD_SEARCH_TASK_HANDLER_GET_STORED_DATA);
            final Val[] values = new Val[storedFields.length];
            final Document document = searcher.getIndexReader().document(docId, fieldsToLoad);

            for (int i = 0; i < storedFields.length; i++) {
                final IndexField storedField = storedFields[i];

                // If the field is null then it isn't stored.
                if (storedField != null) {
                    final IndexableField indexableField = document.getField(storedField.getFldName());

                    // If the field is not in fact stored then it will be null here.
                    if (indexableField != null) {
                        try {
                            values[i] = FieldFactory.convertValue(storedField, indexableField);
                        } catch (final RuntimeException e) {
                            error(errorConsumer, e);
                        }
                    }
                }
            }

            valuesConsumer.accept(Val.of(values));
        } catch (final UncheckedInterruptedException e) {
            throw e;
        } catch (final IOException | RuntimeException e) {
            error(errorConsumer, e);
        }
    }
This method takes a list of document id's and extracts the stored fields
that are required for data display. In some cases such as batch search we
only want to get stream and event ids, in these cases no values are
retrieved, only stream and event ids.
stroom-index/stroom-index-lucene553/src/main/java/stroom/index/lucene553/Lucene553ShardSearcher.java