Articles about European Sharepoint Hosting Service
SharePoint 2013 Hosting – HostForLIFE.eu :: How to Create Result Source In SharePoint 2013 Search Using PowerShell?
This blog post describes how to create a search result source using PowerShell in SharePoint 2013. I have a requirement to add additional search rules which will be used with the keywords entered by the user in the search box, then you will need to create custom search result source. The query will be,
1 |
{searchTerms} Author={User.Name} FileType=pdf FileType=docx |
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
Add-PSSnapin Microsoft.SharePoint.PowerShell $SearchServiceApp = Get-SPEnterpriseSearchServiceApplication $fedmanager = New-Object Microsoft.Office.Server.Search.Administration.Query.FederationManager($SearchServiceApp) $searchOwner = Get-SPEnterpriseSearchOwner -Level Ssa $resultSourceName = "Search" $urlTemplate = "http://yoursharepointsitename/search?q={searchTerms}&format=rss&Market=en-Us" $qT = "{searchTerms}" $ResultSource = $fedmanager.GetSourceByName($resultSourceName, $searchOwner) if(!$ResultSource){ Write-Host "Result source does not exist. Creating." $ResultSource = $fedmanager.CreateSource($searchOwner) } else { Write-Host "Using existing result source." } $ResultSource.Name =$resultSourceName $ResultSource.ProviderId = $fedmanager.ListProviders()['OpenSearch Provider'].Id $ResultSource.ConnectionUrlTemplate = $urlTemplate $ResultSource.CreateQueryTransform($queryProperties,$qT) $ResultSource.Commit() |
Print article | This entry was posted by Peter on July 27, 2017 at 7:17 am, and is filed under Other Related Post. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |