SharePoint Dragons

Nikander & Margriet on SharePoint

Note to Self: Don’t forget to add to indexed properties

If you want to add a property to the spweb property bag, you might want to consider to ad dit to the IndexedPropertyKeys collection as well. This causes the creation of a new crawled property the First time after a full crawl has taken place. The code looks something like this:

using (var site = new SPSite(“http://thesite_coll_url”))

            {

using (var web = site.OpenWeb())

                {

string propKey = “lctest”;

string propValue = “lcvalue”;

                    web.AllProperties[propKey] = propValue;

if (!web.IndexedPropertyKeys.Contains(propKey))

                    {

                        web.IndexedPropertyKeys.Add(propKey);

                    }

                    web.Update();

                }

            }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: