Creating Custom Managed Properties

I speak frequently on the topic of search at various conferences, and one of the challenging parts about this subject is that many of the demos simply take a lot of time.  For example, if I wanted to do a demo about to show how users could search on their own custom fields it would require that I subject the audience to sit there while I run some indexes.  Which is no fun to watch, and I simply don’t have enough bad jokes to keep an audience entertained for more than 30 seconds at the most. 

I’m writing this post as a way to provide the steps required to do that demo for creating your own custom fields.

Quick Summary:

-Create a field in a list or document library. 

-Make sure some items in the list or library have the field and it is filled out.

-Run an incremental crawl to add the field into the index as a crawled property.

-Create a managed property.

-Run a full crawl.

-Wait patiently.

-Enjoy searching on your new managed property.

Longer Explanation:

1) The first step is to create a list or document library with at least one custom field in it.  In my case, I’ve added a column to an existing list called ‘Type of Document’ and made it a Choice field.  This was a very deliberate choice – in larger organizations a Managed Metadata field has a lot of benefits for this type of scenario, but in my case I’m trying to move this along as quickly as possible.  Managed Metadata fields can’t be updated in the datasheet view.  Choice fields can be. And we need the fields to be quickly filled with information so we can then index it….but let’s not get ahead of ourselves.

2) Make sure you’ve got some items in list or document library and using the datasheet view populate the values of your new field. You should be able to select a value and then just like in Excel, click the box in the bottom right corner and drag down to fill the cells below:

 

image

3) Once you’ve filled in some data, the next step is to go to your Search Service Application in Central Administration (Application Management > Manage Service Applications > Search Service Application) and kick off an index.  You can do this by clicking Content Sources from the left navigation.  Then click the dropdown next to Local SharePoint Sites and select Start Incremental Crawl (this assumes you’ve already done a full crawl at some point – if not then click Start Full Crawl)

image

 

On my dev server (without much content) and incremental crawl took anywhere from 2.5 minutes to almost 6 minutes.  This is exactly why I don’t demo this live! 

4)  Once it completes, from the left navigation click on Metadata properties. The from the toolbar across the top click Crawled Properties:

image

5)  To quickly find my new custom column, I typed in ‘type’ into the search box at the top and hit the green arrow.  There were several results that came but, but the one I’m looking for is called": ows_Type_x0020_of_x0020_Document(Text). We aren’t really doing anything special in this step – just proving that our new column got indexed.

image

I know, it has a strange looking name.  This is the internal name for the field.  But we are going to take care of that in the next step.

6) The next thing we are going to do, is create a Managed Property which will take care of that strange looking name for the crawled property.  From the toolbar at the top, click on Managed properties and then New Managed Property.

From the New Managed Property Page fill in the following information into the fields:

Property name: TypeOfDocument

Type of information in this property: Text

To map our column, press the Add Mapping button and in the Crawled property name field enter ‘type’ and press find.  This is about the same process you’d have followed in step 5. Once you’ve located the field, select it and press Ok.

image

You’ll see that the field mapping has now been added to the Mapping to crawled properties field on the New Managed Property page.  Next, place a check in the box to Allow this property to be used in scopes.  Then once complete press OK.  The page should look like this:

image

7) Now, go back to your site.  You can test to see if your managed property works by typing in the following into your search box – make sure you are using the All Sites scope: TypeOfDocument:HR

image

You’ll notice that it doesn’t return any results. That’s because in order for our managed property to work, we’ve got run (another) crawl.  But this time, an incremental crawl isn’t going to work – we’ll have to run a full crawl.  In my case, this took just slightly more than 33 minutes – which brings the total time spent indexing to about 38 minutes. Definitely not something that would make for a great demo to have to watch.

When the full crawl completes, if you run the same query above you’ll get results this time.  That type of query syntax we used for the search is called a restriction.  What we are doing is only searching against our managed property we created for documents that contain HR.  If you happened to have a value such as Human Resources to accommodate for the space, you’d need to enclose the string in quotations like this:  TypeOfDocument:”Human Resources”

Next Steps

Once you’ve created a managed property there’s several other things you can do.  You could create custom search refiners, scopes, customize search results, or even use it to create custom search applications.  But that is the topic of another blog post. 

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: