Elasticsearch Query: Array field length mismatch

Should not be using doc values, as suggested in one of the stackoverflow answers (it's not letting me post the link here)

GET my_index/_search
{
  "_source": ["file_types", "link_to_file"],
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "_id": "45t8724b811b590d54cc1925166a9cb5"
          }
        }
      ]
    }
  },
  "script_fields": {
    "file_types_len": {
      "script": "params._source.file_types.length"
    },
    "link_to_file_len": {
      "script": "params._source.link_to_file.length"
    }
  }
}

Is the way to query.