title: Elasticsearch scripted query painless exponential function
body: <p>With Elasticsearch and painless is there a way to implement an exponential function? I can't seem to find anything. I have something like this.</p>
  
  <pre><code>bdy = {
      "from" : 0,
      "size" : 10,
      "query": {
          "function_score": {
              "query": {
                  "bool": {
                      "must": must_terms
                  }
              },
              "script_score": {
                  "script": {
                  "lang": "expression",
                  "source": "doc['release_year'].value"
                }
              }
          }
      }
  }
  </code></pre>
  
  <p>I want to add some more complex math in the source field, like this.</p>
  
  <pre><code>"source": "Math.exponential(1/doc['release_year'].value)"
  </code></pre>
  
  <p>Is that possible? Or is there another scripting language that you can do that in within elasticsearch?</p>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>Actually looks like I can use. </p>
  
  <pre><code>"lang": "expression"
  "source": "_score/10 + 1/(1+ exp(-(doc['release_year'].value*a)))"
  </code></pre>
  
  <p><a href="http://lucene.apache.org/core/6_0_0/expressions/index.html?org/apache/lucene/expressions/js/package-summary.html" rel="nofollow noreferrer">http://lucene.apache.org/core/6_0_0/expressions/index.html?org/apache/lucene/expressions/js/package-summary.html</a></p>
  
  <p>If anyone has other options that would be cool.</p>