# Script function score default score combiner

**URL:** <https://discuss.elastic.co/t/script-function-score-default-score-combiner/17578>\
**Category:** Elasticsearch\
**Created:** [May 18, 2014, 11:31am UTC](https://discuss.elastic.co/t/script-function-score-default-score-combiner/17578 "2014-05-18T11:31:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meidan](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Meidan](https://discuss.elastic.co/u/Meidan)\
**Post date:** [May 18, 2014, 11:31am UTC](https://discuss.elastic.co/t/script-function-score-default-score-combiner/17578/1 "2014-05-18T11:31:10Z")

</div>

Hello,

I see that ScriptScoreFunction defaults to Replace, which makes total sense:

```
public ScriptScoreFunction(String sScript, Map<String, Object> params, SearchScript script) {
    super(CombineFunction.REPLACE);
    this.sScript = sScript;
    this.params = params;
    this.script = script;
}

```

However, when I try to combine a nested query score into my script score, I  
get the Multiply behavior.

For example, this query will return a score of 1 ((-1)\*(-1)) if I drop the  
line "boost\_mode" : "replace",  
POST \_search  
{  
"query": {  
"function\_score": {  
"boost\_mode" : "replace",  
"query": {  
"nested": {  
"score\_mode": "max",  
"query": {  
"function\_score": {  
"query": {  
"match\_all": {}  
},  
"script\_score": {  
"script": "-1"  
}  
}  
},  
"path": "some\_nested\_path"  
}  
},  
"script\_score": {  
"script": "\_score"  
}  
}  
}  
}

Makes sense to anyone?

Thanks.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/143c4bd7-fbe9-4fc5-a56f-8449e8cdf981%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/143c4bd7-fbe9-4fc5-a56f-8449e8cdf981%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Meidan](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Meidan](https://discuss.elastic.co/u/Meidan)\
**Post date:** [May 18, 2014, 1:48pm UTC](https://discuss.elastic.co/t/script-function-score-default-score-combiner/17578/2 "2014-05-18T13:48:33Z")

</div>

Well documentation says that boost default is indeed Multiply (I was  
looking at the default of combine):

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

So I guess nothing suspicious here 🙂

On Sunday, May 18, 2014 2:31:10 PM UTC+3, Meidan wrote:

> Hello,
> 
> I see that ScriptScoreFunction defaults to Replace, which makes total  
> sense:
> 
> ```
> public ScriptScoreFunction(String sScript, Map<String, Object> params, SearchScript script) {
> super(CombineFunction.REPLACE);
> this.sScript = sScript;
> this.params = params;
> this.script = script;
> }
> 
> ```
> 
> However, when I try to combine a nested query score into my script score,  
> I get the Multiply behavior.
> 
> For example, this query will return a score of 1 ((-1)\*(-1)) if I drop the  
> line "boost\_mode" : "replace",  
> POST \_search  
> {  
> "query": {  
> "function\_score": {  
> "boost\_mode" : "replace",  
> "query": {  
> "nested": {  
> "score\_mode": "max",  
> "query": {  
> "function\_score": {  
> "query": {  
> "match\_all": {}  
> },  
> "script\_score": {  
> "script": "-1"  
> }  
> }  
> },  
> "path": "some\_nested\_path"  
> }  
> },  
> "script\_score": {  
> "script": "\_score"  
> }  
> }  
> }  
> }
> 
> Makes sense to anyone?
> 
> Thanks.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/16d5102a-6773-4af7-9292-43c83b6e23b4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/16d5102a-6773-4af7-9292-43c83b6e23b4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:28am UTC](https://discuss.elastic.co/t/script-function-score-default-score-combiner/17578/3 "2017-07-06T01:28:37Z")

</div>


