fix toXContent, build correct "index" value