Creating Index Partitions using AutoSPInstaller

Aug 15, 2013 at 10:57 AM
Edited Aug 15, 2013 at 10:58 AM
Problem: I have 4 index search servers in my farm, I want to index 20 million documents. This consists of 2 index partitions and 2 index replication nodes.


Using AutoSPInstaller I can create replicas of my only index partition but I can't create index partitions as shown in the image above marked in red.

QU: Looking at the PS, on SP2013 it does not look like the partitions/index partitions are used. Am I correct in thinking AutoSPInstaller can't (ver 3.87) build search with index partitions?
Aug 15, 2013 at 11:26 AM
You are right. 3.87 version doesn't know how to handle more than 1 partition. I typically add them manually after the install via PowerShell. This will be about 6 lines of code.

Something close to the following should help you create Index Partition 1 on your 3rd and 4th server (WFE2 and WFE4)

Add-PSSnapin Microsoft.SharePoint.PowerShell


$ssa = Get-SPEnterpriseSearchServiceApplication #Assuming you have a single Service application
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active

New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $WFE1 -IndexPartition 1
New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $WFE2 -IndexPartition 1

Set-SPEnterpriseSearchTopology -Identity $clone
Aug 15, 2013 at 12:11 PM
Edited Aug 15, 2013 at 12:52 PM
As always - thanks Joseph.

Post about AusoSPInstaller and configuring search.
Aug 18, 2013 at 6:24 AM
Edited Aug 18, 2013 at 6:39 AM
Hi paulbeck

I've customized the autospinstaller 'cause I had the same problem.
What I did:
Addition to the AutoSPInstallerInput.xml:
Inside the <EnterpriseSearchServiceApplication> changed the following part:
            <Server Name="localhost" IndexPartition="0" />
then I made an addition/change to the AutoSPInstallerFunctions.ps1 inside the "If (!($IndexingComponents) ....)" statement:
 Add the following lines:
$indexComponent = ($appConfig.IndexComponent.Server | where {MatchComputerName $_.Name $env:COMPUTERNAME})
$indexPartition = $IndexComponent.IndexPartition
 Changed the following line:
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $searchSvc -IndexPartition $indexPartition @rootDirectorySwitch | Out-Null
I've tested it with two Search Servers each running a separat indexPartition and it worked fine.
Another thing I've changed was, that I had to add the search service account to the local administrator group during the search configuration and removed it later on. This is something I also customized in the AutoSPInstaller and the everything work really fine.

Thanx to everybody who already did great jobs an the existing scripts!
Aug 21, 2013 at 8:54 AM
Davobo, can you please post the complete "If (!($IndexingComponents) ....)" change from the file AutoSPInstallerFunctions.
I also have a question regarding the change in <EnterpriseSearchServiceApplication>. I´ve got a farm with one wfe, one app and two Indexservers. Can I specify the names of the Indexservers or do I have to use localhost?
Aug 21, 2013 at 2:54 PM
Hi Stefanovich
No, you don't have to use 'localhost' as the servername. You can specify for instance:
        <Server Name="WFE1" IndexPartition="0" />
        <Server Name="WFE3" IndexPartition="0" />
        <Server Name="WFE2" IndexPartition="1" />
        <Server Name="WFE4" IndexPartition="1" />
Here is the complete code for the AutoSPInstallerFunctions:
if ($installIndexComponent)
                    if (!($indexingComponents | Where-Object {MatchComputerName $_.ServerName $env:COMPUTERNAME}))
                        Write-Host -ForegroundColor White "Creating..." -NoNewline
                        # Specify the RootDirectory parameter only if it's different than the default path
                        if ($indexLocation -ne "$dataDir\Office Server\Applications")
                        {$rootDirectorySwitch = @{RootDirectory = $indexLocation}}
                        else {$rootDirectorySwitch = ""}
                        $IndexComponent = ($appConfig.IndexComponent.Server | where {MatchComputerName $_.Name $env:COMPUTERNAME})
                        $IndexPartition = $IndexComponent.IndexPartition
                        New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $searchSvc -IndexPartition $IndexPartition @rootDirectorySwitch | Out-Null
                        If ($?)
                            Write-Host -ForegroundColor White "Done."
                            $newComponentsCreated = $true
                    else {Write-Host -ForegroundColor White "Already exists on this server."}
                    $indexComponentReady = $true
Aug 21, 2013 at 4:49 PM
Aug 23, 2013 at 9:42 AM
Hi !

Davobo thanks a lot for your Scripting tips !!
Helped me a lot, really !

Could you please tell us how you managed to add then remove the Search account to local admins during the search partitions creation?

Thanks a lot again !

Aug 23, 2013 at 11:02 AM
Edited Aug 23, 2013 at 11:03 AM
Hi SharePointZone

I've added an additional function to the AutoSPInstallerFunctions.ps1:
# ===================================================================================
# Func: ConfigureSearchServiceAccount
# Desc: adds search service account to Local admins if needed
# ===================================================================================
Function ConfigureSearchServiceAccount([xml]$xmlinput)
    #Add to Admins Group
    $searchServiceAcct = $xmlinput.Configuration.ServiceApps.EnterpriseSearchService.Account
    Write-Host -ForegroundColor White " - Adding $searchServiceAcct to local Administrators (for configuration only)..."
    $searchServiceAcctDomain,$searchServiceAcctUser = $searchServiceAcct -Split "\\"
        $builtinAdminGroup = Get-AdministratorsGroup
    Catch {Write-Host -ForegroundColor White " - $searchServiceAcct is already a member of `"$builtinAdminGroup`"."}
Then I call this function inside the function "CreateEnterpriseSearchServiceApp".
Here is the codesnippet:
function CreateEnterpriseSearchServiceApp([xml]$xmlinput)
    If (ShouldIProvision($xmlinput.Configuration.ServiceApps.EnterpriseSearchService) -eq $true)
        ConfigureSearchServiceAccount $xmlinput
        Write-Host -ForegroundColor White " - Provisioning Enterprise Search..."
        # SLN: Added support for local host
Hope this helps.
Kind regards,
Sep 12, 2013 at 9:39 PM
Many many thanks Danny ! :D
This was GREAT stuffs !!

I've modified the functions as shown previously and built smoothly a partitioned Index on 2 servers :)
(using the 3.93 version)

Just to be sure, please tell me what I have to set at :
<EnterpriseSearchServiceApplication Name="Search Service Application"
  • for 2 servers with 1 partitioned index (I tried with True / 2)
And if supported : (multiple indexes partitions hosted on same server)
  • for 2 servers with 2 partitioned indexes (0/1 1/0)
  • for 3 servers with 3 partitioned indexes (0/1 1/2 0/2)
Hope your snippets will be integrated in next ASPI release !

Thanks a lot !!

Dec 15, 2014 at 3:56 PM
Edited Dec 16, 2014 at 3:14 AM
Has @davobo;s Search topology code made it into, or is it planned to be added to a future release of AutoSPInstaller? Specifically handling for assigning partitions to indexers.

I took @davobo's input example and applied it to my input file, and revised the "3.96" AutoSPInstallerFunctions.ps1 code in the "if ($installIndexComponent)" block, and two partitions were created. = Happiness.
$IndexComponent = ($appConfig.IndexComponent.Server | where {MatchComputerName $_.Name $env:COMPUTERNAME})
$IndexPartition = $IndexComponent.IndexPartition
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $searchSvc -IndexPartition $IndexPartition @rootDirectorySwitch | Out-Null
        <Server Name="WFE1" IndexPartition="0" />
        <Server Name="WFE3" IndexPartition="0" />
        <Server Name="WFE2" IndexPartition="1" />
        <Server Name="WFE4" IndexPartition="1" />