private List<Result> getResults(final SearchRequest searchRequest,
                                    final Map<String, ResultCreator> resultCreatorMap) {

        // Provide results if this search is incremental or the search is complete.
        List<Result> results = new ArrayList<>(searchRequest.getResultRequests().size());
        // Copy the requested portion of the result cache into the result.
        for (final ResultRequest resultRequest : searchRequest.getResultRequests()) {
            final ResultCreator resultCreator = resultCreatorMap.get(resultRequest.getComponentId());
            if (resultCreator != null) {
                final String componentId = resultRequest.getComponentId();

                // Only deliver data to components that actually want it.
                final Fetch fetch = resultRequest.getFetch();
                if (!Fetch.NONE.equals(fetch)) {
                    final DataStore dataStore = store.getData(resultRequest.getComponentId());
                    final Result result = resultCreator.create(dataStore, resultRequest);
                    if (result != null) {
                        // Either we haven't returned a result before or this result
                        // is different from the one delivered previously so deliver it to the client.
                        results.add(result);
                        LOGGER.debug(() -> "Delivering " + result + " for " + componentId);
                    }
                }
            }
        }
        return results;
    }
Build a {@link SearchResponse} from the passed {@link SearchRequest}.

@param searchRequest The {@link SearchRequest} containing the query terms and the result requests
@return A {@link SearchResponse} object that may be one of:
<ul>
<li>A 'complete' {@link SearchResponse} containing all the data requested</li>
<li>An incomplete {@link SearchResponse} containing none, some or all of the data requested, i.e the
currently know results at the point the request is made.</li>
<li>An empty response with an error message indicating the request timed out waiting for a 'complete'
result set. This only applies to non-incremental queries.</li>
<li>An empty response with a different error message. This will happen when some unexpected error has
occurred while assembling the {@link SearchResponse}</li>
</ul>
stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/SearchResponseCreator.java