elastic/elasticsearch

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

Aberta

#136.302 aberto em 9 de out. de 2025

 (2 comentários) (0 reação) (0 responsável)Java (25.882 forks)batch import
:Search Foundations/Search>bugTeam:Search Foundationshelp wanted

Métricas do repositório

Stars
 (76.700 estrelas)
Métricas de merge de PR
 (Mesclagem média 2d) (1.000 fundiu PRs em 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

Guia do colaborador