how search and index works