# Custom Score script: accessing fields outside from the \_source document

**URL:** https://discuss.elastic.co/t/custom-score-script-accessing-fields-outside-from-the--source-document/35346
**Category:** Elasticsearch
**Created:** [November 23, 2015, 6:33pm UTC](https://discuss.elastic.co/t/custom-score-script-accessing-fields-outside-from-the--source-document/35346 "2015-11-23T18:33:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![thiagolocatelli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiagolocatelli/32/6424_2.png) [@thiagolocatelli](https://discuss.elastic.co/u/thiagolocatelli)
#### Post date: [November 23, 2015, 6:33pm UTC](https://discuss.elastic.co/t/custom-score-script-accessing-fields-outside-from-the--source-document/35346/1 "2015-11-23T18:33:11Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 5, 2017, 11:36pm UTC](https://discuss.elastic.co/t/custom-score-script-accessing-fields-outside-from-the--source-document/35346/2 "2017-07-05T23:36:28Z")

</div>


