Create Managed Property from Crawl Property in SharePoint 2013 Search via PowerShell

13. March 2015 08:32 by Rashid Aziz in Sharepoint blogs  //  Tags: ,   //   Comments

I have some custom properties in User Profile. I needed to create managed properties in SharePoint 2013 from custom user profile Crawl properties. I really don’t like doing things manually using SharePoint 2013 central administration site because then I have to recreate these properties on all different environments manually. So here is the script which will do the magic

User profile property name: City 

Crawl property display name: People:City

Crawl property full name: urn:schemas-microsoft-com:sharepoint:portal:profile:City 

You can get the crawl property full name from central admin UI

(Click on “search schema” link from search administration page 

Click “Crawled Properties” link

Search for your property, once it appear in result, click on it.

Crawl property detail page will open and will display the “Property Name” something like “urn:schemas-microsoft-com:sharepoint:portal:profile:City”) 

// Get the search service application

$searchapp = Get-SPEnterpriseSearchServiceApplication

// create base managed property 

$managedProperty_City= New-SPEnterpriseSearchMetadataManagedProperty -Name "City" -SearchApplication $searchapp -Type 1 -Queryable $true -Retrievable $true -FullTextQueriable $true

//Set “Refineable” and “Sortable” properties to true for this newly created managed property, by default these values will be set to false. You can skip this step if you don’t want to set the values to true

$managedProperty_City.Refinable=$true

$managedProperty_City.Sortable=$true

$managedProperty_City.Update()

//Get the crawl property which already exist and map it to the newly created managed property

$crawlProperty_City= Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchapp -Limit 1 -Name "urn:schemas-microsoft-com:sharepoint:portal:profile:City"

New-SPEnterpriseSearchMetadataMapping -SearchApplication $searchapp -ManagedProperty $managedProperty_City -CrawledProperty $crawlProperty_City

Once you run these command, go to search schema page and search for the new managed property “City”. You should see the following result

 

Reference to get parameters detail: https://technet.microsoft.com/en-us/library/ff608089.aspx 

 

blog comments powered by Disqus

Stay connected

SharePoint Links

Month List