How to use runtime mapping on field that is nested

Lets say I have the following document on some index.

{
  "_source" : {
    "process1": {
      "part1": {
        "start": "2022-10-04T18:35:01.540Z",
        "end": "2022-10-04T18:35:01.540Z"
      },
      "part2": {
        "start": "2022-10-04T18:35:38.433Z",
        "end": "2022-10-04T18:35:38.433Z"
      }
    },
    "fileName": "1033977731.PDF",
    "startDate": "2022-10-04T18:35:01.540Z"
    }
  }

What I want to do is create a runtime field so that my documents in the search results have an elaspedTime calculated from a script in a runtime field. I know there is documentation on how to define a runtime field in the mappings, but it not apparent how to do this for nested fields or fields on objects. How would I define the runtime mapping to do this?

{
  "_source" : {
    "process1": {
      "part1": {
        "start": "2022-10-04T18:35:01.540Z",
        "end": "2022-10-04T18:35:01.540Z",
        "elaspedTime": 0 <-- Runtime field
      },
      "part2": {
        "start": "2022-10-04T18:35:38.433Z",
        "end": "2022-10-04T18:35:38.433Z",
        "elaspedTime": 0 <--Runtime field
      }
    },
    "fileName": "1033977731.PDF",
    "startDate": "2022-10-04T18:35:01.540Z"
    }
  }

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.