[FIX] Fixed ticket 1121, a bug in the index construction.