title: Elasticsearch : script_score using a nested value, tagging strength, nested document
body: <p><strong>Mission</strong>
  I am attempting to implement a function score query. 
  <a href="https://stackoverflow.com/questions/13095866/elastic-search-tagging-strength-nested-child-document-boosting">Similar to this post here</a>, only using the new <code>function_score</code>, rather than the old <code>custom_score</code>.</p>
  
  <p><strong>Problem:</strong>
  I am failing to get a value from my script (always returns 0). This leads me to believe attempt to access the weight of the tag by <code>doc['weight'].value</code> is incorrect.</p>
  
  <p><strong>I have three docs that look something like this (all from existing SO post):</strong></p>
  
  <pre><code>{
      "title": "3",
      "tags": [{
          "tag": "B",
          "weight": 16
      }, {
          "tag": "D",
          "weight": 4
      }]
  }
  </code></pre>
  
  <p><strong>My query:</strong></p>
  
  <pre><code>GET test-idx/doc/_search
  {
    "query": {
      "function_score": {
        "query": {
          "nested": {
            "path": "tags",
            "query": {
              "terms": {
                "tag": [
                  "C",
                  "B"
                ],
                "minimum_match": 1
              }
            }
          }
        },
        "functions": [
            { "script_score": { "script": "doc['weight'].value" } }
        ],
        "score_mode": "sum"
      }
    }
  }
  </code></pre>
  
  <p><strong>My Results:</strong></p>
  
  <pre><code>{
     "took": 3,
     "timed_out": false,
     "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
     },
     "hits": {
        "total": 3,
        "max_score": 0,
        "hits": [
           {
              "_index": "test-idx",
              "_type": "doc",
              "_id": "1",
              "_score": 0,
              "_source": {
                 "title": "1",
                 "tags": [
                    {
                       "tag": "A",
                       "weight": 1
                    },
                    {
                       "tag": "B",
                       "weight": 2
                    },
                    {
                       "tag": "C",
                       "weight": 4
                    }
                 ]
              }
           },
           {
              "_index": "test-idx",
              "_type": "doc",
              "_id": "2",
              "_score": 0,
              "_source": {
                 "title": "2",
                 "tags": [
                    {
                       "tag": "B",
                       "weight": 2
                    },
                    {
                       "tag": "C",
                       "weight": 3
                    }
                 ]
              }
           },
           {
              "_index": "test-idx",
              "_type": "doc",
              "_id": "3",
              "_score": 0,
              "_source": {
                 "title": "3",
                 "tags": [
                    {
                       "tag": "B",
                       "weight": 16
                    },
                    {
                       "tag": "D",
                       "weight": 4
                    }
                 ]
              }
           }
        ]
     }
  }
  </code></pre>