Contributors

Thursday 2 May 2013

SharePoint Enterprise Search Provisioning

We have been having issues with Search. Although people were able to search, nothing new was coming into the index. I went to the Search Service Application and realised that nothing was crawling for weeks. When I tried to recreate it, I was getting errors saying that the Administration Component for Search Service Application could not be found. Or something to that effect.

I was getting errors trying to setup crawling again etc so I decided to delete the Search Service Application altogether.

I ran into problems with this. On attempting to delete, it appeared that it did not entirely delete. The databases remained as did the Application itself.

Step 1: Delete Search Service Applications that exist

  • Get-SPServiceInstance (This gets the ID of the Search Service Instance)
  • Remove-SPServiceInstance {GUID} (Paste the GUID of the Service Instance here and press enter
  • Enter Y to confirm
If there is more than one, be sure to remove all of the Search Service Applications

Step 2: Delete Application Pools using the Search Service Application
  • Get-SPServiceApplicationPool
  • Retrieve the names of any application pools that were used for your Search Service Application
  • Remove-SPServiceApplicationPool {Name}
Step 3: Delete any databases
I found that the databases didn't actually delete. Although they weren't listed in SQL Server Management Studio, it appeared that they were still there!!!
  • Get-SPDatabase
  • Remove-SPDatabase {GUID} (Please ensure that you are getting the correct GUID pasted! You don't want to delete any content databases by mistake!!!!)
  • Enter Y to confirm
There are usually 3 search databases named something like the below:

SearchServiceApplication_AdminDB
SearchServiceApplication_AdminDB_CrawlStore
SearchServiceApplication_AdminDB_PropertyStore

Step 4: Provision search using Powershell
You can provision your search using the GUI but I find Powershell much more efficient. I also ran into issues provisioning it on the GUI and retrieved an error saying "Errors Encountered". Lovely and informative, right!!? NOT. In my environment, the Search Service would not start on one of the servers. It was started on the other. You must run the script below on the server that has the Search Service started. Any other server will not work. This is not my script. I found this somewhere in the world wide web several times over! Before you run this, run the Products Configuration Wizard.

# 1.Setting up initial variables.
write-host 1.Setting up initial variables.
$Search_Service_name = "{Name for SearchApplication}"
$Search_Service_account = "{Farm Account}"
$Search_Service_Instance = get-spenterprisesearchserviceinstance -local
$err = $null

# Start Services search services for Search_Service_Instance
write-host Start Services search services for Search_Service_Instance
Start-SPEnterpriseSearchServiceInstance -Identity $Search_Service_Instance

# 2.Create an Application Pool.
write-host 2.Create an Application Pool.
$AppPool = new-SPServiceApplicationPool -name $Search_Service_name"_AppPool" -account $Search_Service_account

# 3.Create the SearchApplicationlication and set it to a variable
write-host 3.Create the SearchApplicationlication and set it to a variable
$SearchApplication = New-SPEnterpriseSearchServiceApplication -Name $Search_Service_name -applicationpool $AppPool -databasename $Search_Service_name"_AdminDB"

#4 Create search service application proxy
write-host 4 Create search service application proxy
$Search_Service_Proxy = new-spenterprisesearchserviceapplicationproxy -name $Search_Service_name"ApplicationProxy" -Uri $SearchApplication.Uri.AbsoluteURI

# 5.Provision Search Admin Component.
write-host 5.Provision Search Admin Component.
set-SPenterprisesearchadministrationcomponent -SearchApplication $SearchApplication  -searchserviceinstance $Search_Service_Instance

# 6.Create a new Crawl Topology.
write-host 6.Create a new Crawl Topology.
$CrawlTopo = $SearchApplication | New-SPEnterpriseSearchCrawlTopology

# 7.Create a new Crawl Store.
write-host 7.Create a new Crawl Store.
$CrawlStore = $SearchApplication | Get-SPEnterpriseSearchCrawlDatabase

# 8.Create a new Crawl Component.
write-host 8.Create a new Crawl Component.
New-SPEnterpriseSearchCrawlComponent -CrawlTopology $CrawlTopo -CrawlDatabase $CrawlStore -SearchServiceInstance $Search_Service_Instance

# 9.Activate the Crawl Topology.
write-host 9.Activate the Crawl Topology.
do
{
    $err = $null
    $CrawlTopo | Set-SPEnterpriseSearchCrawlTopology -Active -ErrorVariable err
    if ($CrawlTopo.State -eq "Active")
    {
        $err = $null
    }
    Start-Sleep -Seconds 10
}
until ($err -eq $null)

# 10.Create a new Query Topology.
write-host 10.Create a new Query Topology.
$QueryTopo = $SearchApplication | New-SPenterpriseSEarchQueryTopology -partitions 1

# 11.Create a variable for the Query Partition
write-host 11.Create a variable for the Query Partition
$Partition1 = ($QueryTopo | Get-SPEnterpriseSearchIndexPartition)

# 12.Create a Query Component.
write-host 12.Create a Query Component.
New-SPEnterpriseSearchQueryComponent -indexpartition $Partition1 -QueryTopology $QueryTopo -SearchServiceInstance $Search_Service_Instance

# 13.Create a variable for the Property Store DB.
write-host 13.Create a variable for the Property Store DB.
$PropDB = $SearchApplication | Get-SPEnterpriseSearchPropertyDatabase

# 14.Set the Query Partition to use the Property Store DB.
write-host 14.Set the Query Partition to use the Property Store DB.
$Partition1 | Set-SPEnterpriseSearchIndexPartition -PropertyDatabase $PropDB

# 15.Activate the Query Topology.
write-host 15.Activate the Query Topology.
do
{
    $err = $null
    $QueryTopo | Set-SPEnterpriseSearchQueryTopology -Active -ErrorVariable err -ErrorAction SilentlyContinue
    Start-Sleep -Seconds 10
    if ($QueryTopo.State -eq "Active")
        {
            $err = $null
        }
}
until ($err -eq $null)

Write-host "Your search application $Search_Service_name is now ready"


Step 5: Start Crawling!

Run a full crawl. You may notice that your search boxes in your environment have gone missing. :o Give it time, once the full crawl is complete and your people crawl is complete, then you can worry over them.

I hope this helps as this took us 3 days to sort :(


No comments:

Post a Comment