Rework processing query for index.