Skip to content

Fix dynamic mapping with dotted field names for vector types#143421

Merged
mayya-sharipova merged 1 commit intoelastic:9.3from
mayya-sharipova:dynamic-udpate-dense-vector
Mar 3, 2026
Merged

Fix dynamic mapping with dotted field names for vector types#143421
mayya-sharipova merged 1 commit intoelastic:9.3from
mayya-sharipova:dynamic-udpate-dense-vector

Conversation

@mayya-sharipova
Copy link
Copy Markdown
Contributor

PR #130540 introduced a bug where indexing a
document with a dotted field name (e.g. "my_vectors.vector1") matched by a dynamic template for dense_vector or rank_vectors without explicit dims would fail with:
IllegalStateException: Missing intermediate object.

The bug only manifests when dims are not set in the mapping or template, triggering the code path that dynamically determines dimensions from the first indexed document.

The root cause is that when DenseVectorFieldMapper and RankVectorsFieldMapper dynamically determine dims, they rebuild the mapper using the document parser's content path. For dynamically mapped fields with dotted names, the content path includes the field name itself rather than just the parent object path, producing a duplicated full path in the rebuilt mapper.

This was fixed on main/9.4 by PR #142754, which refactored dynamic mapper tracking to use Mapper.Builder objects. This commit provides a targeted fix for 9.3.x by deriving the correct parent path from the existing mapper's fullPath instead of relying on the content path.

The same fix is applied to both DenseVectorFieldMapper and RankVectorsFieldMapper, which shared the same bug.

PR elastic#130540 introduced a bug where indexing a
document with a dotted field name (e.g. "my_vectors.vector1") matched
by a dynamic template for dense_vector or rank_vectors without
explicit dims would fail with:
IllegalStateException: Missing intermediate object.

The bug only manifests when dims are not set in the mapping or
template, triggering the code path that dynamically determines
dimensions from the first indexed document.

The root cause is that when DenseVectorFieldMapper and
RankVectorsFieldMapper dynamically determine dims, they rebuild the
mapper using the document parser's content path. For dynamically
mapped fields with dotted names, the content path includes the field
name itself rather than just the parent object path, producing a
duplicated full path in the rebuilt mapper.

This was fixed on main/9.4 by PR elastic#142754, which refactored dynamic
mapper tracking to use Mapper.Builder objects. This commit provides a
targeted fix for 9.3.x by deriving the correct parent path from the
existing mapper's fullPath instead of relying on the content path.

The same fix is applied to both DenseVectorFieldMapper and
RankVectorsFieldMapper, which shared the same bug.
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Mar 2, 2026
Copy link
Copy Markdown
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

I think this is fine :).

@romseygeek you have been playing around with mappers a bunch recently, any strong opinions?

@romseygeek
Copy link
Copy Markdown
Contributor

LGTM. Glad that I accidentally fixed it on main!

@mayya-sharipova mayya-sharipova merged commit bec9323 into elastic:9.3 Mar 3, 2026
35 checks passed
@mayya-sharipova mayya-sharipova deleted the dynamic-udpate-dense-vector branch March 3, 2026 20:35
mayya-sharipova added a commit to mayya-sharipova/elasticsearch that referenced this pull request Mar 4, 2026
PR elastic#143421 introduced test features
mapper.dense_vector.dynamic_template_dotted_field_fix and
mapper.rank_vectors.dynamic_template_dotted_field_fix on the
9.3 branch. The underlying bug was already fixed on 9.4 by

During rolling upgrades test from 9.3 to 9.4 the feature barrier
in NodeJoinExecutor rejects the 9.4 node:

  Node is missing required features
  [mapper.dense_vector.dynamic_template_dotted_field_fix,
   mapper.rank_vectors.dynamic_template_dotted_field_fix]

This PR declares the same NodeFeatures in 9.4 and add the
corresponding YAML regression tests.
mayya-sharipova added a commit that referenced this pull request Mar 4, 2026
PR #143421 introduced test features
mapper.dense_vector.dynamic_template_dotted_field_fix and
mapper.rank_vectors.dynamic_template_dotted_field_fix on the
9.3 branch. The underlying bug was already fixed on 9.4 by

During rolling upgrades test from 9.3 to 9.4 the feature barrier
in NodeJoinExecutor rejects the 9.4 node:

  Node is missing required features
  [mapper.dense_vector.dynamic_template_dotted_field_fix,
   mapper.rank_vectors.dynamic_template_dotted_field_fix]

This PR declares the same NodeFeatures in 9.4 and add the
corresponding YAML regression tests.

* Remove YAML tests for vector dotted field fix
burqen pushed a commit to burqen/elasticsearch that referenced this pull request Mar 5, 2026
PR elastic#143421 introduced test features
mapper.dense_vector.dynamic_template_dotted_field_fix and
mapper.rank_vectors.dynamic_template_dotted_field_fix on the
9.3 branch. The underlying bug was already fixed on 9.4 by

During rolling upgrades test from 9.3 to 9.4 the feature barrier
in NodeJoinExecutor rejects the 9.4 node:

  Node is missing required features
  [mapper.dense_vector.dynamic_template_dotted_field_fix,
   mapper.rank_vectors.dynamic_template_dotted_field_fix]

This PR declares the same NodeFeatures in 9.4 and add the
corresponding YAML regression tests.

* Remove YAML tests for vector dotted field fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Search Relevance/Vectors Vector search Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.3.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants