Skip to content

[9.3] [Transform] Fix transform producing empty dest index when source query references runtime fields (#142450)#142829

Merged
elasticsearchmachine merged 2 commits intoelastic:9.3from
valeriy42:backport/9.3/pr-142450
Feb 23, 2026
Merged

[9.3] [Transform] Fix transform producing empty dest index when source query references runtime fields (#142450)#142829
elasticsearchmachine merged 2 commits intoelastic:9.3from
valeriy42:backport/9.3/pr-142450

Conversation

@valeriy42
Copy link
Contributor

Backport

This will backport the following commits from main to 9.3:

Questions ?

Please refer to the Backport tool documentation

…y references runtime fields (elastic#142450)

When a transform's source query references a runtime field (e.g., a range filter on a runtime-mapped field), the destination index is produced empty even though _transform/_preview returns correct results. The root cause is that ClientTransformIndexer.injectPointInTimeIfNeeded() passes the source query as the PIT indexFilter, but OpenPointInTimeRequest does not support runtime_mappings. During the can_match phase, the query on the unknown runtime field is rewritten to match_none, all shards are filtered out, and the PIT opens with zero search contexts — causing every subsequent search to return empty results. Preview is unaffected because it uses a normal SearchSourceBuilder with both the query and runtime_mappings and does not use PIT.

This change skips the PIT index filter optimization when the source config has non-empty runtime_mappings, since the filter cannot resolve runtime fields. The PIT is still opened for snapshot consistency, just without shard pre-filtering. Additionally, two other code paths that use the source query without propagating runtime_mappings are fixed: the initial progress search in TransformIndexer and the sourceHasChanged check in TimeBasedCheckpointProvider. All three fixes follow the same principle — wherever the source query is used, runtime_mappings from the source config must be propagated alongside it.

Fixes elastic#113156

(cherry picked from commit cf28432)

# Conflicts:
#	x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/ClientTransformIndexerTests.java
@valeriy42 valeriy42 added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Feb 23, 2026
Update SourceConfig constructor calls to match new signature (removed 4th parameter)
and remove CrossProjectModeDecider from TransformServices constructor.

Co-authored-by: Cursor <cursoragent@cursor.com>
@elasticsearchmachine elasticsearchmachine merged commit 12e21f6 into elastic:9.3 Feb 23, 2026
35 checks passed
@valeriy42 valeriy42 deleted the backport/9.3/pr-142450 branch February 23, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport v9.3.2

2 participants