Because our SharePoint products depend on the use of SharePoint metadata (custom column), we often get asked by customers how they can use Sharepoint metadata in Search. Most customers would like to be able to do both full text search and also be able to search based on metadata. For example, if they have defined a metadata column called Project Number, and they want to find all documents related to a particular Project, they should be able to specify the required Project Number in the Advanced Search page in SharePoint. The Advanced Search page does have a property picker that can be be used in search. Unfortunately, by default, the properties listed in the property picker are just some standard SharePoint properties.
Also, customers want to make sure that people only see documents in the Search Results page to which they have permission. In other words, if you don't have permission to the document you should not see it in a search result. In this post I'll dicuss the first part of this request which is how to use custom metadata in Search.
I decided to set this up on my own SharePoint machine to see how this works. My impression after having played a while is that this setup is way more complicated than it should be. There are two parts to this setup:
1) Create a Managed Property which can be used in the search properties.
2) Modify the XML of the Advanced Search web part in order to include your custom metadata as a selectable search property.
Custom metadata is collected by the crawler when it indexes the contents of your SharePoint site. But you must also expose this custom metadata to the users who perform search queries in the Search Center. This procedure assumes the Search functionality is already configured for your Site.
Create managed properties
Use the following procedure to create managed properties.
-
Go to SharePoint Central Administration. Select Application Management, and in the left hand bar Under Shared Services Administration click on your Shared Services website (e.g. SharedServices1)
-
On the Shared Services Administration page, in the Search section, click Search settings.
-
On the Configure Search Settings page, in the Crawl Settings section, click Metadata property mappings. Check to see if your property already exisits. if so, you are good to go. if not, proceed to step 4.
-
On the Metadata Property Mappings page, click New Managed Property.
-
On the New Managed Property page, in the Name and type section, in the Property name box, type the name of the managed property you want to create.
-
In the Description box, type a description for this managed property.
-
Under The type of information in this property, select a property type.
-
In the Mappings to crawled properties section, select one of the following:
-
Include values from all crawled properties mapped. Select this option if you want values from all crawled properties to be mapped. A query for a property in a document in which all crawled properties are mapped returns a result if any of the crawled properties that are mapped match the query.
-
Include values from a single crawled property based on the order specified. Select this option if you want only a single value mapped. When multiple crawled properties are mapped to a managed property, the one that is chosen will be the first in the list that has a value for a given document. You can reorder the list by using the Move up and Move down buttons.
-
-
If you selected Include values from all crawled properties mapped, skip to step 12.
-
Click Add Mapping to add a mapping to the list.
-
The Crawled property selection dialog box appears. Configure the settings as follows:
-
On the Select a category menu, click either All categories or a specific type of document category (for example, Office or SharePoint).
-
In Select a crawled property, select a crawled property to map to the managed property that you are adding.
Because the list of crawled properties is likely to be long, you can type the name (or the first part of the name) of the property that you are looking for in the Crawled property name box and then click Find.
-
Click OK.
-
-
Repeat steps 9 through 10 for each additional crawled property that you want to map to this managed property.
-
On the New Managed Property page, in the Use in scopes section, select the Allow this property to be used in scopes check box if you want this managed property to be available for defining scopes.
-
Click OK.
Once this is done we can now proceed to step #2 which is to modify the Advanced Search page so users will see the property. Here is a screen shot with the Advanced Search page, at the bottom you can see that you can search based on properties. (Click to see larger view)
But by default only the standard SharePoint properties are available in the search as can be seen in this screen shot.
In my case I wanted to add a property called "Department". This custom column in my Document Library lists what department created the document. In order to do this I needed to modify the XML of the Advanced Search Web Part. To do this.
- Go to the Advanced Search Web page.
- From the Site Actions menu select Edit Page.
- Select "Modify Shared Web part" from the Edit menu on the search web part.
- Expand the Properties section and then click on the XML in the Properties box. You should be able to expand the view of the XML by clicking on the ... button.
- Add the property you want to add to both the PropertDef and PropertyRef sections of the XML.
This screen shot shows how I added Department to the PropertyDef section
Once this is done and the web part is saved, you should be able to go back to the Advanced Search page and see your property in the list of properties available for search. Voila! now you can search based on metadata in your custom column.
Of course, metadata can be used for more than just search. If you are interested in using metadata for security have a look at our metadata security blog.