searchs for query by redirecting last letter