Creating and configuring a SharePoint 2013 search service application

The Search Service Application (SSA) in SharePoint provides the content crawl and search functionality. In SharePoint 2010, the Central Administration (CA) site has the option to configure and customize the SSA. This gave the novice and Graphical Interface Administrators (GIA)–this is what I call people who don’t use PowerShell!–an option to add or remove search components such as crawlers, index and query roles, and create mirror copies of search index, etc.

Things have changed quite a bit in SharePoint 2013. Now, there are more components in the SharePoint SSA and to a GIA’s nightmare, there is no way to edit the search topology in Central Administration. We can create a new search service instance but we cannot configure the same.

There are several steps involved in deploying SharePoint Search Service Application.

  • Creating a SharePoint Search Service Application
  • Creating a SSA Proxy
  • Creating an administration component
  • Adding content processing, web analytics, crawler, and query components
  • Adding index component and search index replicas

In this article, I will show you how to create and configure the SharePoint 2013 SSA using PowerShell and customize search topology.

Let us start with an example. Assume that we have a SharePoint 2013 farm with multiple servers hosting different roles. In this farm, we have two web front-end servers, two SQL database servers, and two application servers on which we want to configure all our SharePoint search service components.

For the sake of brevity, the following diagram shows only the SharePoint application servers on which we want to configure the search instance.

SharePoint Search Application Architecture

So, as we see above, we will configure the search administration component on ‘APP Server 01’ and rest all components on both servers for high availability. Also, look at the way index is shown. We will configure two index partitions and ensure both servers have a replica of the index partition.

Note: The following commands need to be run on a server running SharePoint software and you need to load the SharePoint PowerShell snap-in or run these commands at the SharePoint Management Shell. You can load the SharePoint PowerShell snap-in using the following command:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

In this example, we will be running all the commands on ‘APP Server 01’.

The first step in the search service configuration process is to create the search service application. We need a application pool for the search service and we will call it ‘SharePoint_SearchApp’. Also, we need an account for the search service application pool. We will use a domain user account (in my test domain) called SPSearchPool for this purpose. The following code shows how to create a search service application.

$App1 = "APP-Server-01"
$APP2 = "APP-Server-02"
$SearchAppPoolName = "SharePoint_SearchApp"
$SearchAppPoolAccountName = "TestDomain\SPSearchPool"
$SearchServiceName = "SharePoint_Search_Service"
$SearchServiceProxyName = "SharePoint_Search_Proxy"
$DatabaseName = "SharePoint_Search_AdminDB"

#Create a Search Service Application Pool
$spAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose

#Start Search Service Instance on all Application Servers
Start-SPEnterpriseSearchServiceInstance $App1 -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchServiceInstance $App2 -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $App1 -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $App2 -ErrorAction SilentlyContinue

#Create Search Service Application
$ServiceApplication = New-SPEnterpriseSearchServiceApplication -Partitioned -Name $SearchServiceName -ApplicationPool $spAppPool.Name -DatabaseName $DatabaseName

#Create Search Service Proxy
New-SPEnterpriseSearchServiceApplicationProxy -Partitioned -Name $SearchServiceProxyName -SearchApplication $ServiceApplication

We have just created the search service application. Now, we need to configure different search components as described above and then finalize the search topology. Let’s start with creation of the new search topology. For this, we first need to clone the existing active search topology:

$clone = $ServiceApplication.ActiveTopology.Clone()
$App1SSI = Get-SPEnterpriseSearchServiceInstance -Identity $app1
$App2SSI = Get-SPEnterpriseSearchServiceInstance -Identity $app2

Once we have the cloned topology, we can start creating the search components.

#We need only one admin component
New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $App1SSI

#We need two content processing components for HA
New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $App1SSI
New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $App2SSI

#We need two analytics processing components for HA
New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $App1SSI
New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $App2SSI

#We need two crawl components for HA
New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $App1SSI
New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $App2SSI

#We need two query processing components for HA
New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $App1SSI
New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $App2SSI

We created all the search components as per the diagram shown above except the index partitions. As a best practice, we want to place the search index primary copy and replica at different locations on the application servers. The following commands define the locations for the primary and replica copies and then create the index components as required.

#Set the primary and replica index location; ensure these drives and folders exist on application servers
$PrimaryIndexLocation = "E:\Data"
$ReplicaIndexLocation = "F:\Data"

#We need two index partitions and replicas for each partition. Follow the sequence.
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $App1SSI -RootDirectory $PrimaryIndexLocation -IndexPartition 0
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $App2SSI -RootDirectory $ReplicaIndexLocation -IndexPartition 0
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $App2SSI -RootDirectory $PrimaryIndexLocation -IndexPartition 1
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $App1SSI -RootDirectory $ReplicaIndexLocation -IndexPartition 1

Finally, we activate the cloned topology to bring the changes into effect.


This will take a while to finalize the changes. Once the re-configuration of search topology is complete, we can verify the same by running the following commands.

$ssa = Get-SPEnterpriseSearchServiceApplication
Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa

Once the configuration is complete, if you check the search topology on CA site, you should see something similar to what is shown below.

Search Topology

In this article, we looked at only a two-server search topology. But, in real-world, there may be a bigger implementation. However, the steps mentioned in this article can easily be extended to support any size of the farm.

Filed in: Columns, SharePoint2013 Tags: ,

32 Responses to "Creating and configuring a SharePoint 2013 search service application"

  1. Kevin Spreadbury says:

    This may be a typo on your part but in the search service creation script you name servers as:

    $App1 = “APP-Server-01”
    $APP2 = “APP-Server-02”
    When cloning you use different server names.

  2. Arul Soosai Arockiasamy says:

    I am tried to setup my Search Service , but not able to do, can u check I am getting error : New-SPServiceApplicationPool. The Account “SP2013grace” was not found. if it not registered yet, use the New-SPManagedAccount cmdlet.. tks

    • PowerShellMag says:

      Yes, the service application pool account must be a managed account. So, all you need to do is, run the following command before creating a new application pool. New-SPManagedAccount “SP2013grace”

  3. Rajeev Saklani says:

    This is great post to love powershell magic.
    Thanks Ravi

  4. Rahul Prabhune says:

    Very useful information. Thank you.

    If anyone wants to look at SharePoint Search 2013 architecture and configuration


  5. Anjaneyaprasad Cheedepudi says:

    Hi Ravikanth,
    I dont see the databases like Crawl, Link and Analytics in this powershell other than admin database. Will those be created automatically with any default name?

  6. Seth Johnson says:

    Ravikanth, this is a great post! Though I am pretty new to powershell; can i assemble all the above code into one ps script and just run it? does powershell execute from the top down, waiting for code above to finish executing?. or should i run each section of code separately as they are explained in the article? Thank you!

    • Ravikanth says:

      Thanks Seth. You can copy all the lines in the post into a .PS1 file and modify the parts where we specified server names, etc. And, then run the script. It should work. PowerShell execution is linear and it will execute top down.

  7. Daniel Oliemans says:

    How can we delete the search if we want to for some reason? Just like this or this there more behind that I forget:

    $spapp = Get-SPServiceApplication -Name “SharePoint_Search_Service”
    Remove-SPServiceApplication $spapp -RemoveData

  8. Wael Nady says:

    thanks for the amazing script, it worked, except the Index part on server02, i have created folder “D:sp_search_index” on both servers, as i have only partition D: available .

    $PrimaryIndexLocation = “D:sp_search_index”
    #We need two index partitions for each partition.
    New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $App1SSI -RootDirectory $PrimaryIndexLocation -IndexPartition 0
    New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $App2SSI -RootDirectory $PrimaryIndexLocation -IndexPartition 1

    i get this error on server02 category “Crawler:Content Plugin” event ID “2548”
    “Content Plugin can not be initialized – list of CSS addresses is not set”

  9. Laura says:

    I get the message “The load balancer is not provisioned. Verify the load balancer was provisioned successfully before retrieving endpoint addresses.” when searching. Does anyone know how this can be resolved? I have re-created the Search Service Application several times already. The crawler was able to crawl the sites showing successful crawls and more than enough items to return search results. I do not see any account permissions or access issues in DB logs.

    In the ULS after the “UserAgent not available, file operations may not be optimized.” and a few other informational items, the most significant unexpected level is regarding the load balancer:

    Getting user preference failed: System.InvalidOperationException: The load balancer is not provisioned. Verify the load balancer was provisioned successfully before retrieving endpoint addresses.
    at Microsoft.SharePoint.SPServiceLoadBalancer.d__0.MoveNext()
    at Microsoft.SharePoint.SPRoundRobinServiceLoadBalancer.GetEndpoints(IEnumerable1 applicationAddresses)
    at Microsoft.SharePoint.SPRoundRobinServiceLoadBalancer.BeginOperation()
    at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.DoSpLoadBalancedUriWsOp[T](WebServiceBackedOperation
    1 webServiceCall, Int32 timeoutInMilliseconds, Int32 wcfTimeoutInMilliseconds, String operationName)
    at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.DoWebServiceBackedOperation[T](String operationName, Int32 timeoutInMilliseconds, Int32 wcfTimeoutInMilliseconds, WebServiceBackedOperation1 webServiceCall)
    at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.DoWebServiceBackedOperation[T](String operationName, WebServiceBackedOperation
    1 webServiceCall)
    at Microsoft.Office.Server.Search.Administration.UserPreference.GetUserPreference(Boolean lookupFromCache, SPContext context)
    at Microsoft.Office.Server.Search.Administration.UserPreference.GetUserPreference()
    at Microsoft.Office.Server.Search.WebControls.ScriptApplicationManager.FetchServiceAppSettings()

  10. John says:

    I have 4 app servers which I intend to use for search. I have search configured on one of the servers. I moved the search components to the following servers

    Server1 -Admin, Content,crawl,analy,index
    Server2- -Content, Crawl, Analytics, Query
    Server3 –Crawl, Analytics, Query
    Server4 –Crawl, Analytics, Query

    When I tried to move the Admin to the Server2 using the script above . I get the following error

    Unable to retrieve topology component health states. This may be because of the admin component is not up and running

    Is there a way I can provision the search without having to recreate the search service again

    • Ben says:

      go to security>configure manage accounts>add search account.
      then go to
      Configure search accounts> select window service- sharepoint server search
      select search account for this component.

  11. Shashank says:

    How to test load balancing

  12. Mark Janson says:

    I got it to work up to the point of creating Search components, then get the error:

    New-SPEnterpriseAdminComponent : Cannot convert ‘System.Object[]’ to the type ‘Microsoft.Office.Server.Search.Cmdlet.SearchTopologyPipeBind’ required by parameter ‘SearchTopology’. Specified method is not supported.

    Can anybody help out?

  13. Bilal says:

    Thanks , very rich article

  14. Don says:

    These line need to be updated as this is not exactly correct.
    #We need only one admin component
    New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $App1SSI

    You should always have a second or redundant admin component due the fact that if the server running the admin component fails you will lose the whole search service application.

  15. Ram says:

    I have setup 2 app and 2 search servers. After reboot of WFE and Apps servers. All seems to be fine except below message for Search admin page System status for Administrative status, Crawler background activity and Default content access account.

    The search application ‘Search service application’ on server Search1 server is not provisioned. Confirm that the Microsoft SharePoint Foundation Timer service and Central Administration service are running on the server

Leave a Reply

Submit Comment

© 2018 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: