Fix bug in index spec creation and add doc