Error when accessing _index in script_score

Using latest rc1, there's an error if a script_score script references _index (for text scoring):

illegal_argument_exception - Variable [_index] is not defined

Sample query:

GET _search
{
  "query": {
    "function_score": {
      "query": { 
        "match": { "title": "apple" }
      },
      "functions": [ 
        {
          "script_score": {
            "script": {
              "lang": "painless",
              "inline": "_index['title'].docCount()"
            }
          }
        }
      ]
    }
  }
}

Anyone know why there's an error?

It seems _index is not supported in painless language. Change "lang" to "groovy", and the query will work. Also note that you need to turn on groovy inline script in ES 5.