Search API - Is there a way to get position of document in search response hits?

I don't know why, but changing counter type from int to int array solved the issue:

	"script_fields" : {
    "position": {
        "script": {
            "source":"params.counter[0]++",
            "lang":"painless",
            "params":{
                "counter": [0]
            }
    	}
    }
}