A preview call can be quite expensive and cause timeout in a cluster. As a short term fix we identified 2 (hopefully) small fixes:

- make the call cancellable, the main issue here seems to be that preview calls search without using a parent task id(see this fix for data feeds: https://github.com/elastic/elasticsearch/pull/88142/files#diff-aba58244cb8f9dfa3ac3b6efeb02259e3d5956576f56c1ff5e243dd2aac27381)
- pass the timeout parameter of the preview call to the search call, currently a timeout can be specified, but is ignored for the inner search call, which is executed with no timeout (see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html#search-search-api-query-params).

Both changes are bugs and shall be relatively simple to implement and considered for backport to the 7.17 branch.

@przemekwitek can you have a look at this?

related: #88010
x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/rest/action/RestPreviewTransformAction.java
if (Strings.isNullOrEmpty(transformId)) {
            previewRequestHolder.set(PreviewTransformAction.Request.fromXContent(restRequest.contentOrSourceParamParser(), timeout));
        }
        return channel -> {
            RestToXContentListener<PreviewTransformAction.Response> listener = new RestToXContentListener<>(channel);
            if (Strings.isNullOrEmpty(transformId)) {
                PreviewTransformAction.Request previewRequest = previewRequestHolder.get();
                client.execute(PreviewTransformAction.INSTANCE, previewRequest, listener);
            } else {
                GetTransformAction.Request getRequest = new GetTransformAction.Request(transformId);
                getRequest.setAllowNoResources(false);
                client.execute(GetTransformAction.INSTANCE, getRequest, ActionListener.wrap(getResponse -> {
                    List<TransformConfig> transforms = getResponse.getResources().results();
                    if (transforms.size() > 1) {
                        listener.onFailure(
                            ExceptionsHelper.badRequestException(
                                "expected only one config but matched {}",
                                transforms.stream().map(TransformConfig::getId).collect(Collectors.toList())
                            )
                        );
                    } else {
                        PreviewTransformAction.Request previewRequest = new PreviewTransformAction.Request(transforms.get(0), timeout);
                        client.execute(PreviewTransformAction.INSTANCE, previewRequest, listener);
                    }
                }, listener::onFailure));
            }
        };
    }
}