_index not accessible inside external script file?

I am able to run the following query successfully

{
  "query": {
    "match_all": {}
  },
  "aggs": {
    "stadt": {
      "sum": {
        "script": "_index['title']['energy'].tf()"
      }
    }
  },
  "size": 0
}

But I dont want to enable dynamic scripting so I put the content of script into external file inside es/config/scripts/tfscript.groovy

Now the following query throws exception

{
  "query": {
    "match_all": {}
  },
  "aggs": {
    "stadt": {
      "sum": {
        "script": {
          "file": "tfscript"
        }
      }
    }
  },
  "size": 0
}

The exception is

	at org.elasticsearch.search.SearchService.parseSource(SearchService.java:747)
	at org.elasticsearch.search.SearchService.createContext(SearchService.java:572)
	at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:544)
	at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:385)
	at org.elasticsearch.search.action.SearchServiceTransportAction$11.call(SearchServiceTransportAction.java:333)
	at org.elasticsearch.search.action.SearchServiceTransportAction$11.call(SearchServiceTransportAction.java:330)
	at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:559)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.elasticsearch.search.SearchParseException: [enerknol][0]: query[ConstantScore(*:*)],from[-1],size[0]: Parse Failure [Unexpected token START_OBJECT in [stadt].]
	at org.elasticsearch.search.aggregations.metrics.NumericValuesSourceMetricsAggregatorParser.parse(NumericValuesSourceMetricsAggregatorParser.java:61)
	at org.elasticsearch.search.aggregations.AggregatorParsers.parseAggregators(AggregatorParsers.java:148)
	at org.elasticsearch.search.aggregations.AggregatorParsers.parseAggregators(AggregatorParsers.java:78)
	at org.elasticsearch.search.aggregations.AggregationParseElement.parse(AggregationParseElement.java:60)
	at org.elasticsearch.search.SearchService.parseSource(SearchService.java:731)

I searched for Unexpected token START_OBJECT in [stadt] but could not figure out anything.
Am I missing something basic here?