# Support for script\_score in function\_score in Golang client

**URL:** https://discuss.elastic.co/t/support-for-script-score-in-function-score-in-golang-client/350991
**Category:** Elasticsearch
**Created:** [January 12, 2024, 9:34pm UTC](https://discuss.elastic.co/t/support-for-script-score-in-function-score-in-golang-client/350991 "2024-01-12T21:34:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rajivhs](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rajivhs](https://discuss.elastic.co/u/rajivhs)
#### Post date: [January 12, 2024, 9:34pm UTC](https://discuss.elastic.co/t/support-for-script-score-in-function-score-in-golang-client/350991/1 "2024-01-12T21:34:41Z")

</div>

Hi. The docs show the [following example for using script\_score within function\_score](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/filter-search-results.html#multiple-rescores):

```auto
"query" : {
         "score_mode": "multiply",
         "rescore_query" : {
            "function_score" : {
               "script_score": {
                  "script": {
                    "source": "Math.log10(doc.count.value + 2)"
                  }
               }
            }
         }
}

```

The example has `script_score` directly within `function_score`. I'm trying to recreate this using the Go ES library. However, the `FunctionScoreQuery` in the Go lib does not support adding a script\_score directly:

```auto
type FunctionScoreQuery struct {
	Boost *float32 `json:"boost,omitempty"`
	BoostMode *functionboostmode.FunctionBoostMode `json:"boost_mode,omitempty"`
	Functions []FunctionScore `json:"functions,omitempty"`
	MaxBoost *Float64 `json:"max_boost,omitempty"`
	MinScore *Float64 `json:"min_score,omitempty"`
	Query *Query `json:"query,omitempty"`
	QueryName_ *string `json:"_name,omitempty"`
	ScoreMode *functionscoremode.FunctionScoreMode `json:"score_mode,omitempty"`
}

```

Instead, you have to define an array of `functions`, and within the first element, you can define a `script_score`

Is there any difference between using `"function_score" : { "script_score": { ...` vs `"function_score" : { "functions": [{"script_score": {....`? Is there a reason why the Go library does not support the former?

---

<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 9, 2024, 9:35pm UTC](https://discuss.elastic.co/t/support-for-script-score-in-function-score-in-golang-client/350991/2 "2024-02-09T21:35:10Z")

</div>

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