Condividi tramite


Searching Property Bags in SharePoint 2013

This is one of the 1001 or great new things about search in SharePoint 2013. In fact if I had the copious free time that would actually be kind of a fun challenge, writing a 1001 new things I like about Search, but I digress. In this particular case, I'm talking about adding properties to a property bag and getting them indexed and searchable. Fortunately SharePoint 2013 makes this possible, not only for webs, but even all the way down to an SPList. How cool is that? :-)

Here is some PowerShell you can use to get you started with creating an indexed property in an SPWeb property bag:

$web = Get-SPWeb https://localhost
$web.AllProperties["Prop1"] = "value1"
$web.IndexedPropertyKeys.Add("Prop1")
$web.Update()

Next, here's how you add an indexable property to a list:

$list = $web.Lists["Announcements"]
$folder = $list.RootFolder
$folder.Properties["Prop2"] = "Spammers"
$folder.Update()
$list.IndexedRootFolderPropertyKeys.Add("Prop2")
$list.Update()

Of course then just run a full crawl afterward to create the crawled property and all that hoo haw so you end up with a managed property when you're done that is searchable, queryable and retrievable.

Comments

  • Anonymous
    January 01, 2003
    Here's my favorite treatment of the options to implement the same in SP2010.      blogs.msdn.com/.../10097237.aspx A lot of work, and only applies to site metadata. This SP2013 feature is one of my favorite as well.

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    Nice post. Here is one more post explaining to get and set property bag values in SharePoint 2013 apps using CSOM sureshpydi.blogspot.in/.../set-and-get-property-bag-values-in.html

  • Anonymous
    January 01, 2003
    SharePoint Property Bag Settings 2013 is released on CodePlex http://pbs2013.codeplex.com/  

  • Anonymous
    January 01, 2003
    Great feature! A fellow colleague asked me if that was possible with SharePoint 2013. Knowing it was not in SharePoint 2010, I almost gave a negative answer. Then a found this in your blog, thanks a lot.

  • Anonymous
    August 08, 2012
    Nice! Does this work with remote powershell and sharepoint online?

  • Anonymous
    August 28, 2012
    ikr (i know right) i should try that thank you Len (or Thanks Len!)

  • Anonymous
    December 06, 2012
    What Nico said, does this work in SharePoint Online?

  • Anonymous
    December 10, 2012
    Can the property bag values be indexed from the client object model?

  • Anonymous
    April 26, 2013
    Is this property bag the same as the Custom Property of the Term sets? if so, how its made to make this Custom property searchable? thanks

  • Anonymous
    May 17, 2013
    I'd also like to know if it's possible to do this by using client-side code. Do you know this?

  • Anonymous
    March 31, 2014
    I have a questions here. Lets say I have created a property in property bag for SPWeb object for a site, then run full crwal to index the property and its value.
    but when I create another site with same property bag will that site to become queriable do i have to run full crawl or incremental will do or content enrichment is the answer in that case?

  • Anonymous
    September 18, 2014
    The comment has been removed

  • Anonymous
    February 08, 2015
    while running $web.IndexedPropertyKeys.Add("Prop1") on sharepoint online (office 365), its throwing error -
    "System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression."
    Also properties of property bag not crawled automatically in crawled properties.
    Any idea?