Moved the doc/command body creation immediately before bulk index