When adding a script_field to a result, it results in not being able to compile

ES Version: 7.8

I am trying to use the following to check if a value is present in an array of strings, but I get a runtime error every time:

{
  "script": {
    "source": "doc['mediaDetails.tags'].values.contains('Highlight')"
}

Now I get the following when trying other access methods:

{
  "took" : 8,
  "timed_out" : false,
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 1,
    "failures" : [
      {
        "shard" : 0,
        "index" : "videos_eric_meadows",
        "node" : "T453XWINT3mqBPradGk4zQ",
        "reason" : {
          "type" : "script_exception",
          "reason" : "runtime error",
          "script_stack" : [
            "params['_source']['mediaDetails']['primaryTags'].length",
            "                                                ^---- HERE"
          ],
          "script" : "params['_source']['mediaDetails']['primaryTags'].length",
          "lang" : "painless",
          "position" : {
            "offset" : 48,
            "start" : 0,
            "end" : 55
          },
          "caused_by" : {
            "type" : "null_pointer_exception",
            "reason" : "Cannot invoke \"Object.getClass()\" because \"callArgs[0]\" is null"
          }
        }
      }
    ]
  },
  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : 1.0,
    "hits" : [ ]
  }
}

Solved by fixing the field type. The field type was set to int, but when I added in a string, it converted it to text.