# How to assign \_score value to some other field using script\_fields

**URL:** https://discuss.elastic.co/t/how-to-assign-score-value-to-some-other-field-using-script-fields/283531
**Category:** Elasticsearch
**Tags:** painless
**Created:** [September 7, 2021, 12:43pm UTC](https://discuss.elastic.co/t/how-to-assign-score-value-to-some-other-field-using-script-fields/283531 "2021-09-07T12:43:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![voldemort02](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/voldemort02/32/93404_2.png) [@voldemort02](https://discuss.elastic.co/u/voldemort02)
#### Post date: [September 7, 2021, 12:43pm UTC](https://discuss.elastic.co/t/how-to-assign-score-value-to-some-other-field-using-script-fields/283531/1 "2021-09-07T12:43:45Z")

</div>

I would like to inject \_score in my \_source on runtime.  
I used this script but it is not working

```auto
"script_fields": {
    "_score": {
      "script": {
        "lang": "painless",
        "source": "_score.value"
      }
    }
  }

```

---

<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: [October 5, 2021, 12:44pm UTC](https://discuss.elastic.co/t/how-to-assign-score-value-to-some-other-field-using-script-fields/283531/2 "2021-10-05T12:44:11Z")

</div>

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