title: Elasticsearch groovy script to iterate through nested object for scoring throws error
body: <p>I have a nested object <code>mygroup</code> in my document as follows:</p>
  
  <pre><code>{
    "name": "john",
    "mygroup": [
      {
        "start": 200,
        "end": 490
      },
      {
        "start": 800,
        "end": 900
      },
      {
        "start": 22,
        "end": 49
      }
    ]
  }
  </code></pre>
  
  <p>One of my <code>script_score</code> in my <code>function_score</code> is as follows:</p>
  
  <pre><code>"script_score": {
    "params": {
      "gboost": -1350,
      "desired": 30,
      "delta": 10
    },
    "script": "_source['mygroup'].values.any{ if(it -&gt; it.end &gt;= desired &amp;&amp;  it.start &lt;= desired) { return (it.end - delta) * 2} };" 
  }
  </code></pre>
  
  <p>Here my goal is to find an object that matches my condition where <code>start</code> is >= desired AND <code>end</code> &lt;= desired (There is always ONLY one object that will suffice this condition, that's guaranteed in my data storage), once I find that object then I would like to return <code>(it.end - delta) * 2</code> for score calculation</p>
  
  <p>My above script <code>"_source['mygroup'].values.any{ if(it -&gt; it.end &gt;= desired &amp;&amp;  it.start &lt;= desired) { return (it.end - delta) * 2} };"</code> is not working and it keeps throwing error. I am using ES 2.3 and groovy for scripting language.</p>
  
  <p>If I use <code>doc['mygroup']</code> at the place of <code>_source['mygroup']</code>, that also doesn't help</p>