# Is it possible to use ScoreFunctionBuilder/ScoreFunction plugin within script\_score query?

**URL:** https://discuss.elastic.co/t/is-it-possible-to-use-scorefunctionbuilder-scorefunction-plugin-within-script-score-query/364904
**Category:** Elasticsearch
**Created:** [August 14, 2024, 10:03am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-scorefunctionbuilder-scorefunction-plugin-within-script-score-query/364904 "2024-08-14T10:03:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![maartenkroon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maartenkroon/32/136773_2.png) [@maartenkroon](https://discuss.elastic.co/u/maartenkroon)
#### Post date: [August 14, 2024, 10:03am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-scorefunctionbuilder-scorefunction-plugin-within-script-score-query/364904/1 "2024-08-14T10:03:28Z")

</div>

Hi,

I have developed a custom ScoreFunctionBuilder / ScoreFunction as part of Elasticsearch SearchPlugin. I now can use this function "my\_function" within an Elasticsearch query as part of a function\_score query like:

```auto
{
	"query": {
		"function_score": {
			"query": {
				"match_all": {}
			},
			"functions": [
				{
					"my_function": {
						"myarg": "123"
					}
				}
			]
		}
	}
}

```

This works like a charm, so far so good. But should it also be possible to use this custom function in a script within a script\_score query? The following does not work, the function is not recognized:

```auto
{
	"query": {
		"script_score": {
			"query": {
				"match_all": {}
			},
			"script": {
				"source": "my_function('123')"
			}
		}
	}
}

```

Thanks,  
Maarten
