Tuesday, December 4, 2012

Importing Crawled ,Manged Properties from MOSS 2007 to MOSS 2010

Importing Crawled properties & Managed Properties from MOSS 2007 to Moss 2010

Import the crawled and managed properties to XML using Codeplex Utility tool names as "SSSPPC 1.1.1.1"

This tool will generate the following XMLs.
1.output_contentsources.xml
2.output_crawledproperties.xml
3.output_managedproperties.xml
4.output_searchscopes.xml

Use the following Power Shell Script to Import this Crawled & Managed Properties to MOSS 2010.

Function Import-SpSearchManagedProperties([string]$SearchServiceApplication,[string]$FileName){

[System.Xml.XmlDocument] $xd = new-object System.Xml.XmlDocument
$file = resolve-path("output_managedproperties.xml")
$xd.load($file)
$nodelist = $xd.selectnodes("ManagedProperties/ManagedProperty")
$searchapp = Get-SPEnterpriseSearchServiceApplication $SearchServiceApplication
#Create Crawled Propreties
#foreach loop started for creating managed
foreach ($Node in $nodelist) {
$Name = $node.getAttribute("Name")
$type = 1
$ManagedType = $node.getAttribute("ManagedType")
switch ($ManagedType)
{
"Text" {$type = 1}
"Integer" {$type = 2}
"Decimal" {$type = 3}
"DateTime" {$type = 4}
"YesNo" {$type = 5}
"Binary" {$type = 6}
}
if ($managedproperty = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $Name -ea "silentlycontinue")
{
$managedproperty.DeleteAllMappings()
$managedproperty.Delete()
$searchapp.Update()
write-Host "Managed Property Already Exist" -ForegroundColor yellow
}
$managedproperty = New-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Name $Name -Type $type
$managedproperty.EnabledForScoping = $true
$managedproperty.PutInPropertyBlob = $true
$managedproperty.update()
write-Host "New Managed Property Created" -ForegroundColor yellow
$Mappings = $node.selectnodes("CrawledProperties/CrawledPropertyInfo")
foreach ($Mapping in $Mappings){
$CrawledPropset = $Mapping.getAttribute("PropSet")
switch ($CrawledPropset)
{
"0b63e343-9ccc-11d0-bcdb-00805fccce04" {$category="Basic"}

"2edeba9a-0fa8-4020-8a8b-30c3cdf34ccd" {$category="Business Data"}

"28636aa6-953d-11d2-b5d6-00c04fd918d0" {$category="Internal"}

"aa568eec-e0e5-11cf-8fda-00aa00a14f93" {$category="Mail"}

"a373e438-7a87-11d3-b1c1-00c04f68155c" {$category="Notes"}

"d5cdd505-2e9c-101b-9397-08002b2cf9ae" {$category="Office"}

"00110329-0000-0110-c000-000000111146" {$category="People"}

"00130329-0000-0130-c000-000000131346" {$category="SharePoint"}

"d1b5d3f0-c0b3-11cf-9a92-00a0c908dbf1" {$category="Web"}

"" {$category="XML"}

"" {$category="Tiff"}
}
#$category = Get-SPEnterpriseSearchMetadataCategory –Identity $categoryvalue -SearchApplication $searchapp
$CrawledPropertyName = $Mapping.getAttribute("Name")
$CrawledPropertyVariantType = $Mapping.getAttribute("VariantType")
if ($crawledproperty = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $CrawledPropertyName -ea "silentlycontinue")
{
$crawledproperty.DeleteAllMappings()
$crawledproperty.Delete()
$searchapp.Update()
}
$crawledproperty = New-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchapp -Category $category -VariantType $CrawledPropertyVariantType -PropSet $CrawledPropset -Name $CrawledPropertyName -IsNameEnum $false
$cp = get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchapp -Name $CrawledPropertyName
if (($managedproperty -ne $null) -and ($cp -ne $null))
{
New-SPEnterpriseSearchMetadataMapping -SearchApplication $searchapp -ManagedProperty $managedproperty -CrawledProperty $crawledproperty
write-host "Crawled property is mapped with Managed Property"
}
else
{
Write-host "Cannot create managed or crawled property for null values"
}
} # seconf for -loop
} # first for loop closing
write-host "Done"
} #final closing bracket

Import-SpSearchManagedProperties "ContentQuerySSA" "CustomManagedProperties.xml"

No comments:

Post a Comment