Skip to content

Object properties order not preserved in _source for fields with "type": "object", "enabled": false #119347

Closed as not planned
@nemphys

Description

@nemphys

Elasticsearch Version

8.15.2

Installed Plugins

analysis_icu

Java Version

bundled

OS Version

MacOS

Problem Description

According to the documentation (https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html), fields mapped as "type": "object", "enabled": false are supposedly not processed/parsed by Elasticsearch and therefore one would expect that any stored objects in such fields would be stored in the document _source exactly as sent in the indexing request.

This does not seem to be the case when it comes to the order of their properties, since we have cases where such fields inside the document _source (retrieved using a plain GET document request, no searching involved) do not retain the original order.

Eg. a document indexed like this:

{
   fieldA: {
      propA: valueA,
      propB: valueB,
      propC: valueC
   }
}

is returned like this right after it is indexed:

{
   _source: {   
      fieldA: {
          propC: valueC,
          propA: valueA,
          propB: valueB
       }
   }
}

Is this normal/to be expected (ie. object serialization in source fields is not guaranteed to preserve properties order), or is it a bug?

Steps to Reproduce

PUT /test
{
  "mappings": {
    "_source": {
      "enabled": true,
      "excludes": [
        "*.test"
      ]
    },
    "properties": {
      "content": {
        "type": "object",
        "enabled": false
      }
    }
  }
}

PUT /test/_doc/12345678
{
  "content": {
    "propA": [
      "valueA"
    ],
    "propB": [
      "valueB"
    ],
    "propC": [
      "valueC"
    ],
    "propD": [
      "valueD"
    ],
    "propE": [
      "valueE"
    ],
    "propF": [
      "valueF"
    ],
    "propG": [
      "valueG"
    ],
    "propH": [
      "valueH"
    ],
    "propI": [
      "valueI"
    ]
  }
}

GET /test/_doc/12345678

Logs (if relevant)

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions