Create and configure a Search service application in SharePoint Server 2013/2016

Learn how to create and configure a SharePoint Search service application using PowerShell and then how to modify the search topology.

You can create Search service application using Central administration or PowerShell but with  PowerShell , you have more control over the database names and to avoid GUIDs.

Login to the server where All of search components will be hosted whether is configured as a “Search” or “Application with Search” MinRole server, or “Custom”.

Modify the highlighted parameters to be applicable to your SharePoint farm in order to create new search service in one server:

 Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue  
 # Settings   
 $IndexLocation = "D:\Logs\SearchIndex"  
 $SearchAppPoolName = "Search App Pool"   
 $SearchAppPoolAccountName = "domain\spssearch"   
 $SearchServerName = (Get-ChildItem env:computername).value   
 $SearchServiceName = "Test Search Service"   
 $SearchServiceProxyName = "Test Search Proxy"   
 $DatabaseName = "Search_ADminDB"   
 Write-Host -ForegroundColor Yellow "Checking if Search Application Pool exists"   
 $SPAppPool = Get-SPServiceApplicationPool -Identity $SearchAppPoolName -ErrorAction SilentlyContinue  
 if (!$SPAppPool)   
 Write-Host -ForegroundColor Green "Creating Search Application Pool"   
 $spAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose   
 Write-host "Start Search Service instances...."   
 Start-SPEnterpriseSearchServiceInstance $SearchServerName -ErrorAction SilentlyContinue   
 Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $SearchServerName -ErrorAction SilentlyContinue  
 Write-Host -ForegroundColor Yellow "Checking if Search Service Application exists"   
 $ServiceApplication = Get-SPEnterpriseSearchServiceApplication -Identity $SearchServiceName -ErrorAction SilentlyContinue  
 if (!$ServiceApplication)   
 Write-Host -ForegroundColor Green "Creating Search Service Application"   
 $ServiceApplication = New-SPEnterpriseSearchServiceApplication -Partitioned -Name $SearchServiceName -ApplicationPool $spAppPool.Name -DatabaseName $DatabaseName   
 Write-Host -ForegroundColor Yellow "Checking if Search Service Application Proxy exists"   
 $Proxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity $SearchServiceProxyName -ErrorAction SilentlyContinue  
 if (!$Proxy)   
 Write-Host -ForegroundColor Green "Creating Search Service Application Proxy"   
 New-SPEnterpriseSearchServiceApplicationProxy -Partitioned -Name $SearchServiceProxyName -SearchApplication $ServiceApplication   
 Write-Host $ServiceApplication.ActiveTopology  
 Write-Host "Configuring Search Component Topology...."   
 $clone = $ServiceApplication.ActiveTopology.Clone()   
 $SSI = Get-SPEnterpriseSearchServiceInstance -local   
 New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $SSI   
 New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI   
 New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI   
 New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $SSI  
 Remove-Item -Recurse -Force -LiteralPath $IndexLocation -ErrorAction SilentlyContinue   
 mkdir -Path $IndexLocation -Force  
 New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $SSI -RootDirectory $IndexLocation   
 New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI   
 Write-host "Your search service application $SearchServiceName is now ready"  

Next step to modify the topology to match your requirement, let assume that we have 4 SharePoint Servers (2 as web servers and 2 as Search servers) , in this case we can divide the search components as following:


So Query Processing and Index Partition will be hosted in front end or web servers and the rest of search components will be hosted in Search or Application Servers because no direct interaction with end users.

1- Run SharePoint service on each host that will used to run the search components

$host1 = Get-SPEnterpriseSearchServiceInstance -Identity "server1"  
 $host2 = Get-SPEnterpriseSearchServiceInstance -Identity "server2"  
 $host3 = Get-SPEnterpriseSearchServiceInstance -Identity "appserver1"  
 $host4 = Get-SPEnterpriseSearchServiceInstance -Identity "appserver2"  
 Start-SPEnterpriseSearchServiceInstance -Identity $host1  
 Start-SPEnterpriseSearchServiceInstance -Identity $host2  
 Start-SPEnterpriseSearchServiceInstance -Identity $host3  
 Start-SPEnterpriseSearchServiceInstance -Identity $host4  

Don’t go to the next commands until all servers become Online, you can check the status using the following command:


2- Get Current Topology

 $ssa = Get-SPEnterpriseSearchServiceApplication  

3- Clone Current Topology to modify it

 $newSSA = New-SPEnterpriseSearchTopology -SearchApplication $ssa  

4- Create Search Components for each host

 #Recommanded in WFE Server (Query Component and Indexes only)  
 New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newSSA -SearchServiceInstance $host1  
 New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newSSA -SearchServiceInstance $host2  
 New-SPEnterpriseSearchIndexComponent -SearchTopology $newSSA -SearchServiceInstance $host1 -IndexPartition 0  
 New-SPEnterpriseSearchIndexComponent -SearchTopology $newSSA -SearchServiceInstance $host2 -IndexPartition 0  
 #Recommanded in Application Server (Admin , Crawl , Content Processing and Analytics processing)  
 New-SPEnterpriseSearchAdminComponent -SearchTopology $newSSA -SearchServiceInstance $host3  
 New-SPEnterpriseSearchCrawlComponent -SearchTopology $newSSA -SearchServiceInstance $host3  
 New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newSSA -SearchServiceInstance $host3  
 New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newSSA -SearchServiceInstance $host3  
 New-SPEnterpriseSearchAdminComponent -SearchTopology $newSSA -SearchServiceInstance $host4  
 New-SPEnterpriseSearchCrawlComponent -SearchTopology $newSSA -SearchServiceInstance $host4  
 New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newSSA -SearchServiceInstance $host4  
 New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newSSA -SearchServiceInstance $host4  

5- Activate New Topology

 Set-SPEnterpriseSearchTopology -Identity $newSSA  

It’s recommended to remove the inActive topologies to avoid confusion in future, you can find how to remove it and change search service account in the following link:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s