Skip to content

Painless Execution API does not work with documents which has nested types #41004

@csenol

Description

@csenol

Elasticsearch version
6.5.4 and above

Plugins installed: []

JVM version
1.8.0, jdk10, jdk11, jdk12
OS version
linux

Description of the problem including expected versus actual behavior:

When using painless execution API, documents with nested field types are empty

Steps to reproduce:

curl -X PUT "localhost:9200/test0" -H 'Content-Type: application/json' -d'       

{
    "mappings" : {
        "_doc" : {
            "properties" : {
                "field0": {"type": "long"},
                "field1" : {   "type": "nested",
                                "properties": {
                                        "nested1": {
                                           "type": "integer"}
                                }
                           }
            }
        }
    }
}
 curl -X PUT "localhost:9200/test0/_doc/1" -H 'Content-Type: application/json' -d'
{
    "field0" : 12, "field1": [{"nested1":1}]                                 
}   
'  
curl -X POST "localhost:9200/_scripts/painless/_execute" -H 'Content-Type: application/json' -d'
{
  "script": {
    "source": "return doc[\"field0\"].value    ",
    "params": {
      "number": 1
    }
  },
  "context_setup": {
    "index": "test0",
    "document": {
      "field0": 3,
      "field1": [
        {
          "nested1": 2
        }
      ]
    }
  },
  "context": "score"
}

'

{"result":0.0}

It was expected to have result 3 instead of 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Core/Infra/ScriptingScripting abstractions, Painless, and Mustache>bugTeam:Core/InfraMeta label for core/infra teamtriagedIssue has been looked at, and is being left open

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions