Work Item Search & Code Search allow TFS users to do advanced and dynamic way of quick searching on code or work items, with drill down etc. To enable Code Search in VSTS you have to install the Marketplace extension for code search, work item search is default enabled for VSTS. You can configure search for on-premises TFS in TFS AT (described here), itself. But if you want to setup search service in a separate box from your TFS AT, you can follow the steps described in this post.
First download and install Java Runtime Environment 8 (JRE) update 20 or higher to the machine you are configuring as search server. The set the JAVA_HOME to the installed location.
In your TFS 2018 AT go to Admin Console and launch Search configuration wizard. Select the option for “Use an existing Search Service”. Click on the provided link to locate the search service package available in your TFS AT.
README.txt contains the information you need to configure the search service. In a administrative PowerShell window run the script Configure-TFSSearch.ps1 providing install path and search index path. It is recommended to have 35% of all collection DBs size or more hard disk space in index path.
When you run the readiness checks you might encounter an issue due to firewall blocking the search service port you have configured. Allow that port only for the requests coming from your TFS AT by creating a custom firewall rule.
Code search and work item search will be available for the TFS instance. You can switch between them using the small dropdown.