# Add more than one custom script in function\_score

**URL:** <https://discuss.elastic.co/t/add-more-than-one-custom-script-in-function-score/14154>\
**Category:** Elasticsearch\
**Created:** [October 29, 2013, 12:29pm UTC](https://discuss.elastic.co/t/add-more-than-one-custom-script-in-function-score/14154 "2013-10-29T12:29:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mromagnoli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mromagnoli/32/839_2.png) [@mromagnoli](https://discuss.elastic.co/u/mromagnoli)\
**Post date:** [October 29, 2013, 12:29pm UTC](https://discuss.elastic.co/t/add-more-than-one-custom-script-in-function-score/14154/1 "2013-10-29T12:29:09Z")

</div>

My doubt is about putting more than one custom script in my funtion score.  
Is that possible?

I have something like this:

POST /lz/listing/\_search?pretty=true  
{  
"from": 1,  
"size": 20,  
"query": {  
"function\_score": {  
"query": {  
"bool": {  
"should": [{  
"multi\_match": {  
"query": "pizza",  
"fields": ["Listing.name.standard^10"],  
"use\_dis\_max": false  
}  
}],  
"must": {  
"terms": {  
"Zone.id": ["1"]  
}  
},  
"minimum\_should\_match": 1  
}  
},  
"script\_score": {  
"params": {  
"times": 10,  
"default": 0.1  
},  
"script": ["doc['Review.id'].empty ? \_score \* default :  
\_score \* doc['Review.id'].values.length \* times"]  
}  
}  
},  
"sort": ["\_score"],  
"track\_scores": true  
}

Is there any way to indicate that the score has to take in account de  
script set in 'script\_score' and another one like in an "or"|"and" filter  
or something like that?

I think like this:

"script\_score": {  
"params": {  
"times": 10,  
"default": 0.1  
},  
"script": [  
"doc['Review.id'].empty ? \_score \* default : \_score

- doc['Review.id'].values.length \* times",  
"doc['Bookmark.id'].empty ? \_score \* default :  
\_score \* doc['Bookmark.id'].values.length \* times"  
]  
}

Hope I was clear 😉

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:10am UTC](https://discuss.elastic.co/t/add-more-than-one-custom-script-in-function-score/14154/2 "2017-07-06T02:10:02Z")

</div>


