SharePoint 2013: Configure Search using PowerShell (Part 1 of 2)
Configuring the Multi Farm SharePoint 2013 Search Service application
Application pool
The first step is to create an Application Pool which will be used by search service application:
$appPool = New-SPServiceApplicationPool -name "ssaAppPool" -account contoso\girish
Start the search service instance on all the servers (WFE and Application server)
$host 1 = Get-SPEnterpriseSearchServiceInstance -Identity "GIRISHDSCS-APP1"
$host 2 = Get-SPEnterpriseSearchServiceInstance -Identity "GIRISHDSCS-APP2"
$host 3 = Get-SPEnterpriseSearchServiceInstance -Identity "GIRISHDSCS-WEB1"
$host 4 = Get-SPEnterpriseSearchServiceInstance -Identity "GIRISHDSCS-WEB2"
Start-SPEnterpriseSearchServiceInstance -Identity $host 1
Start-SPEnterpriseSearchServiceInstance -Identity $host 2
Start-SPEnterpriseSearchServiceInstance -Identity $host 3
Start-SPEnterpriseSearchServiceInstance -Identity $host 4
Start the search query and site settings service instance on the Application server:
$host 1 = Get-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance -Identity 'GIRISHDSCS-APP1'
$host 2 = Get-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance -Identity 'GIRISHDSCS-APP2'
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $host 1
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $host 2
Set the custom index location
$indexPath = "path of the custom index location"
$searchServiceInstance 1 = Get-SPEnterpriseSearchServiceInstance -Identity "GIRISHDSCS-APP1"
$searchServiceInstance 1 | Set-SPEnterpriseSearchServiceInstance -DefaultIndexLocation $indexPath
$searchServiceInstance 2 = Get-SPEnterpriseSearchServiceInstance -Identity "GIRISHDSCS-APP2"
$searchServiceInstance 2 | Set-SPEnterpriseSearchServiceInstance -DefaultIndexLocation $indexPath
$searchServiceInstance 3 = Get-SPEnterpriseSearchServiceInstance -Identity "GIRISHDSCS-WEB1"
$searchServiceInstance 4 | Set-SPEnterpriseSearchServiceInstance -DefaultIndexLocation $indexPath
$searchServiceInstance 4 = Get-SPEnterpriseSearchServiceInstance -Identity "GIRISHDSCS-WEB2"
$searchServiceInstance 4 | Set-SPEnterpriseSearchServiceInstance -DefaultIndexLocation $indexPath
Create the search service application and proxy:
$searchServiceApp = New-SPEnterpriseSearchServiceApplication -Name "Search Service Application" -ApplicationPool "ssaAppPool" -DatabaseName "SearchServiceApplication_DB"
$searchServiceAppProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "Search Service Application Proxy" -SearchApplication $searchServiceApp
Now the search service application is created as shown:
New search topology
Create the new search topology that is associated with the search service applications:
$searchServiceApplication = Get-SPEnterpriseSearchServiceApplication "Search Service Application"
$initialTopology = Get-SPEnterpriseSearchTopology -SearchApplication $searchServiceApplication -Active
$newSearchTopology = New-SPEnterpriseSearchTopology -SearchApplication $searchServiceApplication -Clone -SearchTopology $initialTopology
Search admin components
Create the search admin components
New-SPEnterpriseSearchAdminComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host1
New-SPEnterpriseSearchCrawlComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host1
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host1
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host1
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host2
New-SPEnterpriseSearchIndexComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host2
New-SPEnterpriseSearchAdminComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host3
New-SPEnterpriseSearchCrawlComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host3
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host3
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host3
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host4
New-SPEnterpriseSearchIndexComponent -SearchTopology $newSearchTopology -SearchServiceInstance $host4 -IndexPartition 0
Activate the search topology:
Set-SPEnterpriseSearchTopology -Identity $newSearchTopology
$initialTopology = Get-SPEnterpriseSearchTopology -SearchApplication $searchServiceApplication | ? {($_.State) -eq "Inactive" }
Remove-SPEnterpriseSearchTopology -Identity $initialTopology -Confirm:$false
The search topology will be as follows: