Skip to content

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

@5k4nd

Description

@5k4nd

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions