How to check if a Property is marked as Searchable

blog header image

A couple of times I've been asked how to check if a property on a page is set to be Searchable. It can be very handy to know, if you are making a search engine integration - or any other kind of textual processing of EPiServer CMS content, for that matter. And I know I haven't been alone in wondering why it's not exposed on the PropertyData object. However, the answer is simply, that it doesn't belong there. It's a piece of meta-data set on the definition on a property - and not on the property itself. In order words, it's one abstraction level above the PropertyData object.

To get access to the SearchAble, LanguageSpecific, etc properties look at the PageDefinition class - for instance like this:

PropertyData pd = CurrentPage.Property["MainBody"];
bool isSearchable = 
PageDefinition.Load(pd.PageDefinitionID).Searchable;
Recent posts