public/index.php starts the admin context when the path begins with /admin, otherwise the website context. On the console the script decides: bin/adminconsole and bin/console run in the admin context, bin/websiteconsole in the website context. That is why you clear both caches. The search index is also built once per context.