# Groovy Scripting optional paramters

**URL:** <https://discuss.elastic.co/t/groovy-scripting-optional-paramters/230835>\
**Category:** Elasticsearch\
**Created:** [May 3, 2020, 12:05am UTC](https://discuss.elastic.co/t/groovy-scripting-optional-paramters/230835 "2020-05-03T00:05:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![teebu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/teebu/32/10119_2.png) [@teebu](https://discuss.elastic.co/u/teebu)\
**Post date:** [May 3, 2020, 12:05am UTC](https://discuss.elastic.co/t/groovy-scripting-optional-paramters/230835/1 "2020-05-03T00:05:19Z")

</div>

I'm trying to figure out how to have optional params with default value.

My script is simple:

```auto
{
  "script": "doc[field].empty ? 0 : (201 - doc[field]) * boost"
}

```

I want the boost to default to 1 if its omitted in the call.

---

<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:** [May 31, 2020, 12:05am UTC](https://discuss.elastic.co/t/groovy-scripting-optional-paramters/230835/2 "2020-05-31T00:05:25Z")

</div>

Closed on May 31, 2020, 12:05am UTC

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