Writing SharePoint 2013 feels very new to me, but I created my first Demo environment and tried to set up search.
What needs to be done?
14 steps for a simple Search Topology – 1 powershell can do them all.
- Create a Service Application Pool for the Search Service Application (15-22)
- Create a Search Service Application (22-28)
- Create a Search Service Application Proxy (30-36)
- Get the current Search Instance (38)
- Save the current Search Topology for later use (39)
- Create a new Search Topology (40)
- Create all the Search Components (Analytics- , Content Processing, Query Processing, Crawler-, Admin Component) (42-46)
- Remove the Index-Folder and recreate it (50-51)
- Create a new Index Component (53)
- Activate the new Topology (56)
- Call the method synchronize on the old topology – this errors but forces an update on the old topology object (59)
- The “forced updated” Topology object becomes inactive and can be deleted. (62)
- Everything done – start a full crawl oder set it to the new shiny continuous crawling. Enjoy!
The numbers in the braces are the line numbers in the powershell script following now.
Powershell to the rescue!
Here is my powershell script for creating the whole service application and creating a basic topology.
Please keep in mind that the $IndexLocation folder will be deleted and recreated.
Adjust the settings in the lines 4-11 to your needs.
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$IndexLocation = "C:\Search" #Location must be empty, will be deleted during the process!
$SearchAppPoolName = "Search App Pool"
$SearchAppPoolAccountName = "demo\SPSearchAppPool"
$SearchServiceName = "Search SA"
$SearchServiceProxyName = "Search SA Proxy"
$DatabaseServer = "sp2013\sharepoint"
$DatabaseName = "SP2013 Search"
Write-Host -ForegroundColor Yellow "Checking if Search Application Pool exists"
$spAppPool = Get-SPServiceApplicationPool -Identity $SearchAppPoolName -ErrorAction SilentlyContinue
Write-Host -ForegroundColor Green "Creating Search Application Pool"
$spAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose
Write-Host -ForegroundColor Yellow "Checking if Search Service Application exists"
$ServiceApplication = Get-SPEnterpriseSearchServiceApplication -Identity $SearchServiceName -ErrorAction SilentlyContinue
Write-Host -ForegroundColor Green "Creating Search Service Application"
$ServiceApplication = New-SPEnterpriseSearchServiceApplication -Name $SearchServiceName -ApplicationPool $spAppPool.Name -DatabaseServer $DatabaseServer -DatabaseName $DatabaseName
Write-Host -ForegroundColor Yellow "Checking if Search Service Application Proxy exists"
$Proxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity $SearchServiceProxyName -ErrorAction SilentlyContinue
Write-Host -ForegroundColor Green "Creating Search Service Application Proxy"
New-SPEnterpriseSearchServiceApplicationProxy -Name $SearchServiceProxyName -SearchApplication $SearchServiceName
$searchInstance = Get-SPEnterpriseSearchServiceInstance -local
$InitialSearchTopology = $ServiceApplication | Get-SPEnterpriseSearchTopology -Active
$SearchTopology = $ServiceApplication | New-SPEnterpriseSearchTopology
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance
New-SPEnterpriseSearchCrawlComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance
New-SPEnterpriseSearchAdminComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance
set-SPEnterpriseSearchAdministrationComponent -SearchApplication $ServiceApplication -SearchServiceInstance $searchInstance
Remove-Item -Recurse -Force -LiteralPath $IndexLocation -ErrorAction SilentlyContinue
mkdir -Path $IndexLocation -Force
New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology -SearchServiceInstance $searchInstance -RootDirectory $IndexLocation
Write-Host -ForegroundColor Green "Activating new topology"
Write-Host -ForegroundColor Yellow "Next call will provoke an error but after that the old topology can be deleted - just ignore it!"
Write-Host -ForegroundColor Yellow "Deleting old topology"
Remove-SPEnterpriseSearchTopology -Identity $InitialSearchTopology -Confirm:$false
Write-Host -ForegroundColor Green "Old topology deleted"
Write-Host -ForegroundColor Green "Done - start a full crawl and you are good to go (search)."
The whole script took about 3 minutes on my machine.
I took some parts from here, but received some errors, some paramaters were missing so I adjusted the script for my needs.
The MSDN documentation is missing that there is a timer job responsible for topology changes – ULSViewer helped me to figure that one out.
Update 1, 24.07.2012 17:11
I exchanged some emails with Alpesh Nakar (funnily he created a script for the same thing) and he helped me reducing my script a lot. Thanks for that.
Did it work for you?
Max has led SharePoint implementations for Dax 30 companies since 2009.
Max’s free time is spent on twitter mostly with a good coffee in his hands.
Latest posts by Max Melcher (see all)
- Enterprise Productivity & Search – June 2016 - June 23, 2016
- User Group Munich: SharePoint 2016 Hybrid with Samuel Zuercher - June 20, 2016
- TFS 2015 Upgrade to Update 1 failed (VS402388 / TF401147) - March 8, 2016