By: Rahul Mehta | Comments | Related: > SharePoint
Problem
In SharePoint 2010, one of the most frequent enhancement requests that come from clients is to add a custom property to property restrictions in the (Out of The Box) advance search box.
By default, properties like Author, Description, Name and others are provided in property restrictions. But how about a case users want to search documents of a particular department only or some other field criteria?
Solution
SharePoint 2010 by default doesn't provide a direct way to add site columns in search parameters searching. But with a little configuring, we can add this functionality.
Lets follow the steps below:
- Add a site Column and data to a list/library.
- Make a Crawled Property of that Site column.
- Create a mapped property map to the Crawled Property that was created.
- Add a mapped property to the advance search web part to avail users to select it in the search web part.
Let's start by adding a site/list/library column. To add a site column go to a List or Library, then go to the Ribbon and click on Create Column. Give it a meaningful name (like "OrganizationDepartment"). Select type as "Text" and click "OK".
![organizations docs](/tipimages_sharepoint/3970_1.jpg)
After adding a site/list/library column, we need to create a crawled property for it.
Go to Central Administration -> Application Management -> Search Service Application -> Crawling Section -> Content Sources.
![crawling](/tipimages_sharepoint/3970_2.jpg)
To search the data of our site/list/library column, we need to crawl the content so it can be discovered during the search. Select the appropriate content source, open the context menu and click on "Start Incremental Crawl".
![start incremental crawl](/tipimages_sharepoint/3970_3.jpg)
Once it is finished, go back to the search service application and go to:
Queries and Results -> Metadata Properties.
![metadata properties](/tipimages_sharepoint/3970_4.jpg)
Select "Crawled Properties":
![crawled properties](/tipimages_sharepoint/3970_5.jpg)
One can search the crawled properties (in our case by "Organization") Below we see a property named "ows_OrganizationDepartment(Text)".
![managed properties](/tipimages_sharepoint/3970_6.jpg)
If you see the above property, we're halfway there.To create a mapped property, go to Central Administration -> Application Management -> Search Service Application -> Queries and Results -> Metadata Properties. Click on "New managed property".
![new managed property](/tipimages_sharepoint/3970_1b.jpg)
In next screen, we need to some additional fields as follows:
Property name: DocsDepartment
Property Type: Text
We also need to select the crawled properties (single or all). In our case, we will map to a single property. Click on Add Mapping.
![property name](/tipimages_sharepoint/3970_2b.jpg)
Search for a crawled property like "Organization" and you would find the property "ows_OrganizationDepartment(Text). Select the property and click "OK".
![crawled property selection](/tipimages_sharepoint/3970_3b.jpg)
After that, we go back to the property creation scene.
Make sure that the options "Include values from a single crawled property based on the order specified" and "Allow this property to be used in scopes" are selected. Click OK.
![include values](/tipimages_sharepoint/3970_4b.jpg)
Now go to the Advanced search web part page and edit the advanced search web part. Under the properties section, click on Properties and edit.
![advanced search box](/tipimages_sharepoint/3970_5b.jpg)
We need to add our property to "PropertyDefs" and to all result types like "All Results" in which we want our parameter to be used. After adding, click Apply and OK and close the web part properties.
![property defintion](/tipimages_sharepoint/3970_6b.jpg)
Now if you go to Property Restrictions, you can see the newly added property "DocsDepartment".
![add property restrictions](/tipimages_sharepoint/3970_7b.jpg)
Go ahead and use the property for searching results. If everything goes fine, you will get results like the one below:
![department test](/tipimages_sharepoint/3970_8b.jpg)
This way you can use any metadata as a search parameter to get desired results.
Next Steps
- Check out these other articles:
About the author
![MSSQLTips author Rahul Mehta](/images/Rahul-Mehta.jpg)
This author pledges the content of this article is based on professional experience and not AI generated.
View all my tips