Fix the index build with LSI

Fixes issue #1039