Custom Score script: accessing fields outside from the _source document

Hi all,

I have an alias that points to multiple indexes and I am running a Function Score Query (I am currently using spring-boot and spring-data-elasticsearch) against this alias, so my result will contain different type of documents.

I need to access the "_type" property from the script so I can change the score if move up some documents that belong to a specific type.

"script_score": {
    "script": "_score * (_type == 'PEOPLE' ? 5 : 1) * (_type == 'GENRE' ? 7 : 1)"
  }`

However, when I run this query I getting the following exception:

GroovyScriptExecutionException[MissingPropertyException[No such property: _type for class: 0c2482e5a867a67f8e95abd4a7a54346948c1a66]];

Is there a way I can access fields that actually do not belong to the _source document? Since _score is available, I was wondering if _type would be available too.

Any ideas?
Thank you
Thiago