Мысли вслух…

PowerShell functions to create crawled/managed properties

Автор: Июл.27.2012 Категория: SharePoint

Today I refactored powershell scripts for FASTSearch server.

So, I moved the same code to functions, as result you may see: CreateCrawledProperty/CreateManagedProperty/MapCrawledPropertyToManagedProperty

Usage:

CreateCrawledProperty "propName" 31
CreateManagedProperty  "propName" 1 1 0
MapCrawledPropertyToManagedProperty "crawledPropName" "managedPropName"

Source code you may see below.

function CreateCrawledProperty([string]$crawledPropertyName, [int] $varType = 31)
{
$crawledProperty = Get-FASTSearchMetadataCrawledProperty -Name $crawledPropertyName -ErrorAction SilentlyContinue
if ($crawledProperty -eq $null) {
New-FASTSearchMetadataCrawledProperty -Name $crawledPropertyName -Propset $uspsCategoryGuid -VariantType $varType
$crawledProperty = Get-FASTSearchMetadataCrawledProperty -Name $crawledPropertyName
}
return $crawledProperty
}

function CreateManagedProperty([string]$managedPropertyName, [int] $type = 1, [int] $refinementEnabled = 1, [int] $mergeCrawledProperties = 1)
{
$managedProperty = Get-FASTSearchMetadataManagedProperty -Name $managedPropertyName -ErrorAction SilentlyContinue
if ($managedProperty -eq $null) {
New-FASTSearchMetadataManagedProperty -Name $managedPropertyName -Type $type
$managedProperty = Get-FASTSearchMetadataManagedProperty -Name $managedPropertyName
Set-FASTSearchMetadataManagedProperty -ManagedProperty $managedProperty -RefinementEnabled $refinementEnabled -MergeCrawledProperties $mergeCrawledProperties
}
return $managedProperty
}

function MapCrawledPropertyToManagedProperty([string]$crawledPropertyName, [string]$managedPropertyName)
{
$crawledProperty = Get-FASTSearchMetadataCrawledProperty -Name $crawledPropertyName -ErrorAction Stop
$managedProperty = Get-FASTSearchMetadataManagedProperty -Name $managedPropertyName -ErrorAction Stop
$crawledPropertyMapping = $managedProperty.GetCrawledPropertyMappings()
$crawledPropertyCategoryList = $crawledPropertyMapping | Where-Object {$_.CategoryName -match $uspsCategoryName}
if ($crawledPropertyCategoryList -eq $null) {
$crawledPropertyMapping.Insert(0, $crawledProperty)
Set-FASTSearchMetadataCrawledPropertyMapping -CrawledPropertyMapping $crawledPropertyMapping -ManagedProperty $managedProperty
}
}
:

Leave a Reply

:bad: :beer: :biggrin: :blink: :blush: :bomb: :confused: :cool: :crazy: :cry: :dont_know: :eek: :evil: :dance: :heart: :idea: :joke: :kiss: :lol: :mad: :music: :rose: :sad: :smile: :surprised: :tongue: :yahoo: :wall: :wink:
 

Поиск

Список друзей