Is your Business Analyst, and business unit going mad over best bets slowly editing them to get ready for go-live, have hundreds to import into Sharepoint 2010, we used the below CSV layout and Powershell script to import Best Bets. This will keep them happy for a while and get them off your back ;) I obtained this from this great post http://get-spscripts.com/2010/10/create-search-keywords-and-best-bets.html
CSV column layout below
Keyword,Definition,Synonyms,BestBet1,Description1,Url1,BestBet2,Description2,Url2,BestBet3,Description3,Url3
Powershell Script to import CSV file
function Import-SearchKeywords ($SiteUrl, $CSVFilePath, [switch]$RemoveOldKeywords)
{
$ssap = Get-SPEnterpriseSearchServiceApplicationProxy -Identity “Search Service Application2″
$keywords = New-Object Microsoft.Office.Server.Search.Administration.Keywords($ssap, $SiteUrl)
$allKeywords = $keywords.AllKeywords
$date = Get-Date
#Remove all previous keywords from the site collection if chosen
if($RemoveOldKeywords) {
$keywordsArray = @()
$allKeywords | ForEach-Object {
$keywordsArray = $keywordsArray + $_.Term
}
$keywordsArray | ForEach-Object {
write-host “Deleting keyword:”$_
$allKeywords[$_].Delete()
}
}
#Import CSV file
$csvData = Import-Csv $CSVFilePath | ForEach-Object {
#Create keyword
write-host “Importing keyword:”$_.Keyword
$keyword = $allKeywords.Create($_.Keyword, $date.AddHours(-1))
$keyword.Definition = $_.Definition
#Create synonyms
$synonymArray = @()
$synonymArray = $_.Synonyms.Split(“;”)
$synonymArray | ForEach-Object {
write-host “Creating synonym”$_ “for keyword” $keyword.Term
$keyword.Synonyms.Create($_)
}
#Create best bets
$bestBetColumnNumber = 1
$bestBetColumn = “BestBet” + $bestBetColumnNumber
$descriptionColumn = “Description” + $bestBetColumnNumber
$urlColumn = “Url” + $bestBetColumnNumber
while ($_.$bestBetColumn) {
write-host “Creating best bet”$_.$bestBetColumn “for keyword” $keyword.Term
$keyword.BestBets.Create($_.$bestBetColumn, $_.$descriptionColumn, $_.$urlColumn)
$bestBetColumnNumber = $bestBetColumnNumber + 1
$bestBetColumn = “BestBet” + $bestBetColumnNumber
$descriptionColumn = “Description” + $bestBetColumnNumber
$urlColumn = “Url” + $bestBetColumnNumber
}
#Update keyword with best bets
$keyword.Update()
}
}
Import-SearchKeywords –SiteUrl <enter site url> –CSVFilePath C:\BestBet.txt -RemoveOldKeywords
Thanks! Really helpful.
ReplyDeleteWithout delay this web site is likely to indisputably regularly get outstanding pertaining to every bit of webpage customers, by reason of fastidious information and likewise medical tests. 메이저사이트
ReplyDelete