Access Nested Objects using Painless for Alerting to Create Trigger Condition

I am to create Trigger condition in Monitor in Opensearch.I was trying to extract fields present in _source which is giving error "reason" : "Illegal list shortcut value [_source].".

DSL Extraction Query-

{
    "size": 1,
    "sort": {"Date" : "desc" },
    "query": {
        "bool": {
            "filter": [
                {
                    "range": {
                        "Date": {
                            "from": "{{period_end}}||-3d",
                            "to": "{{period_end}}",
                            "include_lower": true,
                            "include_upper": true,
                            "format": "epoch_millis",
                            "boost": 1
                        }
                    }
                }
            ],
            "adjust_pure_negative": true,
            "boost": 1
        }
    },
    "aggregations": {
        "metric": {
            "avg": {
                "field": "difference"
            }
        }
    }
}

Output-

{
    "_shards": {
        "total": 4,
        "failed": 0,
        "successful": 4,
        "skipped": 2
    },
    "hits": {
        "hits": [
            {
                "_index": "reliance_cal_spread",
                "_source": {
                    "symbol": "RELIANCE",
                    "std_dev": 2.4,
                    "upper_range": 10.3,
                    "current_month_close": 2536.3,
                    "mean": 7.9,
                    "weekday": "Tuesday",
                    "difference": 3,
                    "Date": "2022-06-28T00:00:00",
                    "next_month_close": 2539.3,
                    "lower_range": 5.5
                },
                "_id": "E2-cqoEB0vMP3J-sGCIB",
                "sort": [
                    1656374400000
                ],
                "_score": null
            }
        ],
        "total": {
            "value": 2,
            "relation": "eq"
        },
        "max_score": null
    },
    "took": 8,
    "timed_out": false,
    "aggregations": {
        "metric": {
            "value": 2.799999952316284
        }
    }
}

Trigger Condition-

return ctx.results[0].aggregations.metric.value == null ? false :ctx.results[0].hits.hits._source.difference > 6

Error-

{
  "type" : "script_exception",
  "reason" : "runtime error",
  "script_stack" : [
    "return ctx.results[0].aggregations.metric.value == null ? false :ctx.results[0].hits.hits._source.difference > 6",
    "                                                                                         ^---- HERE"
  ],
  "script" : "return ctx.results[0].aggregations.metric.value == null ? false :ctx.results[0].hits.hits._source.difference > 6",
  "lang" : "painless",
  "position" : {
    "offset" : 89,
    "start" : 0,
    "end" : 112
  },
  "caused_by" : {
    "type" : "illegal_argument_exception",
    "reason" : "Illegal list shortcut value [_source]."
  }
}

While I am able to extract other conditions such as-aggregations.metric.value and hits.total.value.

Trigger Condition

return ctx.results[0].aggregations.metric.value == null ? false :ctx.results[0].aggregations.metric.value < 6

Trigger Condition Response-

True