How to: Delete Crawled Properties

Posted Tuesday, February 26, 2008 9:36 AM by CoreyRoth

This unfortunately is not as simple as it should be.  Out of the box, there is not an option to delete a single crawled property.  I sort of understand the reason behind this, but when developing its very easy to get your crawled properties filled with a bunch of garbage as you are trying things out.  It would be nice to clean that up.  So how do you do it?  Your only option is to make use of a setting on each category of crawled properties (i.e.: SharePoint, Business Data, People), labeled Delete all unmapped crawled properties.  You can get there by clicking the Edit Category link after choosing a Crawled Property.  To make use of this, you would need to remove any mapping of crawled properties you don't want to keep first.  I don't really like this as an option all that much, especially when you are removing things from the SharePoint category.  Unfortunately, this appears to be the only way to do it other than going directly to the database (which obviously is not recommended).

Examining the API, there is nothing in there to delete a single crawled property either.  However, you can also use the API to do the above mentioned step if you want.  Include a reference to Microsoft.SharePoint and Microsoft.Office.Server.Search.Administration.  Here is the code to delete the unmapped properties.

using (SPSite currentSiteCollection = new SPSite("http://mossserver"))

{

    // the schema class actually represents managed and crawled proeperties

    Schema schema = new Schema(SearchContext.GetContext(currentSiteCollection));

 

    // get the sharepoint category

    Category category = schema.AllCategories("SharePoint");

 

    // delete all unmapped properties

    category.DeleteUnmappedProperties();

 

    // after delete an update is required

    category.Update();

}

Comments

# re: How to: Delete Crawled Properties

Monday, June 2, 2008 1:50 AM by bertvan

I'm under the impression that checking the Delete Unmapped Properties doesn't do much either... I have some crawled properties wich are no longer used in lists, and no longer mapped, but still won't be deleted.

Isn't there any other way to force this?

# re: How to: Delete Crawled Properties

Sunday, September 26, 2010 6:42 AM by ShareNew

Where to put that code ?

# re: How to: Delete Crawled Properties

Monday, September 27, 2010 8:36 AM by CoreyRoth

@ShareNew You can put it wherever you like such as in a console application.

# re: How to: Delete Crawled Properties

Wednesday, October 27, 2010 11:03 AM by Sandeep

Not working

# re: How to: Delete Crawled Properties

Friday, January 21, 2011 4:49 AM by Dave

It worked but my SSP kept disappearing/corrupting so I took the code out...

# re: How to: Delete Crawled Properties

Wednesday, August 17, 2011 7:10 AM by brad

Hi Corey, I am assuming this is the same in SP2010? i.e. there is no powershell you can use to delete a specific crawled property you have created, like you say in development id like to quickly be able to remove a crawled property as the delete unmapped does not always appear to work..

# re: How to: Delete Crawled Properties

Tuesday, August 30, 2011 10:50 AM by CoreyRoth

@Brad Exactly the same unfortunately.

# re: How to: Delete Crawled Properties

Monday, October 31, 2011 3:01 PM by Musch

Hi Cory, great article - and thanks for pointing me in the right direction.

I modified your code for some pseudo PowerShell (and SP2010 object model) code :)

$searchApp = Get-SPEnterpriseSearchServiceApplication "MySearchApp"

$schema = New-Object Microsoft.Office.Server.Search.Administration.Schema –ArgumentList $searchApp

$category = $schema.AllCategories["SharePoint"];

$category.DeleteUnmappedProperties();  

$category.Update();  

# re: How to: Delete Crawled Properties

Monday, November 7, 2011 8:39 PM by CoreyRoth

@Musch thanks for the PowerShell script!

# re: How to: Delete Crawled Properties

Friday, December 23, 2011 6:06 AM by Adrian Johnson

Great article, some quick and dirty PS to do this in FAST (first powershell i've ever written :)

Replace the URL with your CA address and "JDBC" with whichever category you want.

Thanks

$site = Get-SPSite "http://localhost:81/"

$serviceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site)

$searchProxy = [Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy]::GetProxy($serviceContext)

$schemaContext = $searchProxy.FASTAdminProxy.SchemaContext

$schema = $schemaContext.Schema

$category = $schema.AllCategories["JDBC"]

$category.DeleteUnmappedProperties()

$category.Update()

# re: How to: Delete Crawled Properties

Friday, January 20, 2012 3:36 AM by Joakim

Do delete a crawled property, it mustn't be included in the index as well. Edit the property and uncheck the "Include values for this property in the search index", for it to be purged with the above methods.

# re: How to: Delete Crawled Properties

Tuesday, June 5, 2012 4:20 PM by Joe

Remove-SPEnterpriseSearchMetadataManagedProperty (sp2010)

# re: How to: Delete Crawled Properties

Friday, September 7, 2012 2:25 AM by Mark van Dijk

Thanks Corey, I've written a complementary blog article focussed on FAST: markspoint.blogspot.nl/.../remove-crawled-properties-in-fast.html

# Deleting Crawled Properties | SharePoint interests

Friday, December 12, 2014 9:49 AM by Deleting Crawled Properties | SharePoint interests

Pingback from  Deleting Crawled Properties | SharePoint interests

Leave a Comment

(required)
(required)
(optional)
(required)