public DashboardSearchRequest createDownloadQueryRequest(final ExpressionOperator expression,
                                                             final List<Param> params,
                                                             final TimeRange timeRange) {
        Search search = null;
        final Map<String, ComponentSettings> resultComponentMap = createComponentSettingsMap();
        if (resultComponentMap != null) {
            final DocRef dataSourceRef = indexLoader.getLoadedDataSourceRef();
            if (dataSourceRef != null && expression != null) {
                // Copy the expression.
                final ExpressionOperator currentExpression = ExpressionUtil.copyOperator(expression);

                search = Search
                        .builder()
                        .dataSourceRef(dataSourceRef)
                        .expression(currentExpression)
                        .componentSettingsMap(resultComponentMap)
                        .params(params)
                        .timeRange(timeRange)
                        .build();
            }
        }

        if (search == null || resultComponents.size() == 0) {
            return null;
        }

        final List<ComponentResultRequest> requests = new ArrayList<>();
        for (final Entry<String, ResultComponent> entry : resultComponents.entrySet()) {
            final ResultComponent resultComponent = entry.getValue();
            final ComponentResultRequest componentResultRequest = resultComponent.createDownloadQueryRequest();
            requests.add(componentResultRequest);
        }

        return DashboardSearchRequest
                .builder()
                .searchRequestSource(getSearchRequestSource())
                .search(search)
                .componentResultRequests(requests)
                .dateTimeSettings(dateTimeSettingsFactory.getDateTimeSettings())
                .build();
    }
Initialises the model for passed expression and current result settings and returns
the corresponding {@link DashboardSearchRequest} object
stroom-core-client/src/main/java/stroom/dashboard/client/main/SearchModel.java