# Accessing unindexed fields in script\_score

**URL:** <https://discuss.elastic.co/t/accessing-unindexed-fields-in-script-score/165248>\
**Category:** Elasticsearch\
**Created:** [January 22, 2019, 2:07pm UTC](https://discuss.elastic.co/t/accessing-unindexed-fields-in-script-score/165248 "2019-01-22T14:07:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![halaei](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/halaei/32/40076_2.png) [@halaei](https://discuss.elastic.co/u/halaei)\
**Post date:** [January 22, 2019, 2:07pm UTC](https://discuss.elastic.co/t/accessing-unindexed-fields-in-script-score/165248/1 "2019-01-22T14:07:37Z")

</div>

Does accessing fields that are not indexed in script\_score imposes extra time penalty? In other words, should I index all the fields that my script access, even if they are not queried?

```
Sample part of my schema:
{
    ...
    "likes": {"type": "integer, "indexed": false}
}

```

A sample script:

```
return Math.log(doc['likes'].value)

```

Also I want to know if the time spent in accessing document fields adds up to fetch time or they are part of the query time (which are reported by index/\_stats api).

Thanks.

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [January 23, 2019, 1:19am UTC](https://discuss.elastic.co/t/accessing-unindexed-fields-in-script-score/165248/2 "2019-01-23T01:19:18Z")

</div>

A script\_score is part of the query time. Accessing fields through `doc` is as fast as can be done. This is separate from whether the field is indexed, in a separate data structure in Lucene.

---

<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:** [February 20, 2019, 1:19am UTC](https://discuss.elastic.co/t/accessing-unindexed-fields-in-script-score/165248/3 "2019-02-20T01:19:18Z")

</div>

Closed on February 20, 2019, 1:19am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
