Search query works correctly by searching for ranges