Is it possible to make Managed Property for a taxonomy term without creating a corresponding site column. I want to make my MMS terms and termsets and having corresponding refined Managed Property and corresponding Crawled Property, without creating a taxonomy field on the site. (I want to use it in REST API Search query). thanks.
1 Answer
You can use PowerShell to create a Crawled property and a managed property.
You can use the following code to create and map the properties
Param(
[string]$crawledProp,
[string]$managedProp,
[int] $typeManagedProp
)
# TypemanagedProp 1 = Text 2 = Integer 3 = Decimal 4 = DateTime 5 = YesNo 6 = Binary 7 = Double
$snapin = "Microsoft.SharePoint.PowerShell"
if ((Get-PSSnapin -Name $snapin -ErrorAction SilentlyContinue) -eq $null)
{
Write-Host -ForegroundColor Green "PSsnapin $snapin is registered"
Add-PsSnapin $snapin
Write-Host -ForegroundColor Green "PSsnapin $snapin is loaded"
}
$searchapp = Get-SPEnterpriseSearchServiceApplication
$category = Get-SPEnterpriseSearchMetadataCategory –SearchApplication $searchapp –Identity SharePoint
$crawlpropTemplate = Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchapp -Category $category –Limit 1
$cProp = Get-SPEnterpriseSearchMetadataCrawledProperty -Name $crawledProp -Category $crawlpropTemplate.CategoryName -SearchApplication $searchapp
if ($cProp -eq $null)
{
Write-Host -ForegroundColor Yellow "Creating CrawledProperty '$crawledProp' " -NoNewline
$cProp = New-SPEnterpriseSearchMetadataCrawledProperty -Name $crawledProp -VariantType $crawlpropTemplate.VariantType -Category $crawlpropTemplate.CategoryName -PropSet $crawlpropTemplate.PropSet -SearchApplication $searchapp -IsNameEnum $false
Write-Host -ForegroundColor Green " - Done."
}
$mProp = Get-SPEnterpriseSearchMetadataManagedProperty -Identity $managedProp -SearchApplication $searchapp -ErrorAction SilentlyContinue
if ($mProp -eq $null)
{
Write-Host -ForegroundColor Yellow "Creating ManagedProperty '$managedProp' " -NoNewline
$mProp = New-SPEnterpriseSearchMetadataManagedProperty -Name $managedProp -Type $typeManagedProp -SearchApplication $searchapp -ErrorAction:SilentlyContinue
$mProp.Refinable = $true
$mProp.Update()
Write-Host -ForegroundColor Green " - Done."
}
if( $mProp -eq $null -or $cProp -eq $null)
{
Write-Host -ForegroundColor Red "Mapping not created "
if( $mProp -eq $null)
{
Write-Host -ForegroundColor Red " - ManagedProperty is Null"
}
if( $cProp -eq $null)
{
Write-Host -ForegroundColor Red " - CrawledProperty is Null"
}
}
else
{
$mapping = Get-SPEnterpriseSearchMetadataMapping -ManagedProperty $mProp -CrawledProperty $cProp -SearchApplication $searchapp
if( $mapping -eq $null)
{
Write-Host -ForegroundColor Yellow "Creating mapping between '$crawledProp' and '$managedProp' " -NoNewline
$mapping = New-SPEnterpriseSearchMetadataMapping -ManagedProperty $mProp -CrawledProperty $cProp -SearchApplication $searchapp
Write-Host -ForegroundColor Green " - Done."
}
}
Write-Host " "
-
thank you. I enabled a TermSet for Faceted Navigation, When I go to Terms to add a Managed Property and click Customize Refiners it generates following error: No suggested refiners are displayed, because no refiner values are found in the data tagged with this term. have any idea why?– MedesApr 25, 2013 at 9:07