Migrate queryIndex to the new sparse index format