Skip to content

Runtime fields: pass down runtime field name as source filter when source mode is synthetic#133897

Merged
martijnvg merged 22 commits intoelastic:mainfrom
martijnvg:runtime_fields_synthetic_source
Sep 4, 2025
Merged

Runtime fields: pass down runtime field name as source filter when source mode is synthetic#133897
martijnvg merged 22 commits intoelastic:mainfrom
martijnvg:runtime_fields_synthetic_source

Conversation

@martijnvg
Copy link
Member

@martijnvg martijnvg commented Sep 1, 2025

If runtime fields have no scripts, then use the runtime field name as source filter.
This avoids synthesizing fields that are not requested

…thetic

This avoids synthesizing fields that are not requested
@martijnvg martijnvg added the :StorageEngine/Mapping The storage related side of mappings label Sep 1, 2025
}

/** Returns {@code true} if the script only parses a field from source */
default boolean isParsedFromSource() {
Copy link
Member Author

@martijnvg martijnvg Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically for runtime fields without a script:

"runtime": {
...
          "agent.version": {
            "type": "keyword"
          },
...
}
@martijnvg martijnvg changed the title Pass down runtime field name as source filter when source mode is synthetic Sep 2, 2025
@martijnvg martijnvg added the :Search Foundations/Mapping Index mappings, including merging and defining field types label Sep 2, 2025
@martijnvg martijnvg marked this pull request as ready for review September 2, 2025 12:29
@elasticsearchmachine elasticsearchmachine added Team:StorageEngine Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch labels Sep 2, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

@elasticsearchmachine
Copy link
Collaborator

Hi @martijnvg, I've created a changelog YAML for you.

martijnvg and others added 2 commits September 2, 2025 15:19
Co-authored-by: Kostas Krikellas <131142368+kkrik-es@users.noreply.github.com>
MapperService mapperService = createMapperService(mapping);
SearchExecutionContext c = createSearchExecutionContext(mapperService);
{
var fieldType = (AbstractScriptFieldType) c.getFieldType("field_source");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear why one uses the optimized path vs the other, mind adding a comment?

Copy link
Contributor

@jordan-powers jordan-powers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍, thanks Martijn

@martijnvg martijnvg enabled auto-merge (squash) September 4, 2025 05:06
@martijnvg martijnvg merged commit 5b6bb47 into elastic:main Sep 4, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types :StorageEngine/Mapping The storage related side of mappings Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch Team:StorageEngine v9.2.0

4 participants