Skip to content

Conversation

@nielsbauman
Copy link
Contributor

When we create a new MapperService from an existing index for validation purposes, we often merge the mappings of the existing index into the temporary mapper service right after. This requires parsing the mappings and "merging" them (there's not much merging to do with an empty service, but we still need to traverse the mappings object). This can take up considerable time for larger mappings.

By passing the existing DocumentMapper instance of the index (if available) to the new MapperService, the aforementioned mapping merge becomes a no-op and saves all that redundant processing.

When we create a new `MapperService` from an existing index for
validation purposes, we often merge the mappings of the existing index
into the temporary mapper service right after. This requires parsing the
mappings and "merging" them (there's not much merging to do with an
empty service, but we still need to traverse the mappings object). This
can take up considerable time for larger mappings.

By passing the existing `DocumentMapper` instance of the index (if
available) to the new `MapperService`, the aforementioned mapping merge
becomes a no-op and saves all that redundant processing.
@nielsbauman nielsbauman added >enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types labels Nov 24, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@nielsbauman
Copy link
Contributor Author

These changes are related to #138367, but can be merged/viewed separately. I performed similar benchmarks for this PR as well. See #138367 (comment) for a brief explanation of what experiments I performed.

Here is the same flamegraph on main (the first flamegraph in the comment I linked):
image
flamegraph-mappings-main-noop-pr.html

And here is the flamegraph on this PR:
image
flamegraph-mappings-only-mapper-copy-noop.html

The rightmost merge/parse path completely disappeared, saving a lot of processing.

@nielsbauman nielsbauman marked this pull request as ready for review November 24, 2025 11:15
@elasticsearchmachine elasticsearchmachine added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Nov 24, 2025
@elasticsearchmachine
Copy link
Collaborator

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

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 Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants