elastic/elasticsearch

Source filtering fails for nested fields under backslash-named parent field

Open

#136,302 opened on Oct 9, 2025

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Java (25,882 forks)batch import
:Search Foundations/Search>bugTeam:Search Foundationshelp wanted

Repository metrics

Stars
 (76,700 stars)
PR merge metrics
 (Avg merge 2d 5h) (1,000 merged PRs in 30d)

Description

Elasticsearch Version

9.1.5

Installed Plugins

No response

Java Version

bundled

OS Version

Darwin Kernel Version 24.6.0: Mon Aug 11 21:16:34 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6020 arm64

Problem Description

Source filtering using _source parameter fails to return nested fields when the parent field name is a backslash (\) character. This worked correctly in version 8.5.3 but stopped working starting from 8.6.0.

Steps to Reproduce

  1. Create an index with a backslash-named field containing nested properties:
PUT test
{
  "mappings": {
    "properties": {
      "\\": {
        "properties": {
          "nested_value": {
            "type": "text"
          }
        }
      }
    }
  }
}
  1. Index a document:
POST test/_doc?refresh
{
  "\\": {
    "nested_value": "value_C"
  }
}
  1. Query with source filtering for the parent field (works correctly):
GET test/_search
{
  "_source": ["\\"]
}

Result: Returns the full \ object with its nested_value ✅

  1. Query with source filtering for the nested field (fails):
GET test/_search
{
  "_source": ["\\.nested_value"]
}

Result: Returns empty source ❌

Expected behavior: The query in step 4 should return:

{
  "hits": {
    "hits": [
      {
        "_source": {
          "\\": {
            "nested_value": "value_C"
          }
        }
      }
    ]
  }
}

Actual behavior: The query returns documents but with empty _source:

{
  "hits": {
    "hits": [
      {
        "_source": {}
      }
    ]
  }
}
  • This is a regression: the same query worked correctly in version 8.5.3. It still does not work in 9.1.5
  • The issue specifically affects field paths where the parent field name is a backslash character
  • Fetching the parent field \ directly works, but accessing nested properties via dot notation fails

Logs (if relevant)

No response

Contributor guide