Update the query to support 2-level index