Two of the great new things about MOSS2007 are Content Types and the extensibility of the Search function. Put the two together and very quickly you’ll come up with the scenario where you’ve created a nice comprehensive set of metadata which you’ve now applied to all the sites and libraries in your site collection, and now you want search on those metadata items.
The Advanced Search web part (typically surfaced through the Search Centre) looks like it’s going to do the job for you, with a drop down box which lets you restrict your search based on properties, but out-of-the-box it quickly becomes apparent that only a subset of the standard properties are there, not your own site columns. The ones you get as standard are:
Author
Description
Name
Size (MB)
URL
Created Date
Last Modified Date
Created By
Last Modified By
There are a couple of additional steps which you have to carry out to make your own appear there, most of which have been documented in various places but I couldn’t find a complete end-to-end walk through for the process, so this is it.
Firstly, I’ve assumed that you’ve already set up the site columns, assembled them as content types, and made those content types available within the document libraries of your sites. In my case, I have a set of them which form the core metadata schema for my customer – a mixture of default and bespoke ones.
Contributor (multiline) default
Date Created (date/time) default
Disposal Action (choice) bespoke
Disposal Date (date/time) bespoke
Disposal Review (date/time) bespoke
Document Type (choice) bespoke
Relation (multiline) default
Title (single line) default
Topic (choice) bespoke
Created By (person/group) default
Modified By (person/group) default
Checked Out To (person/group) default
The problem comes about because within Sharepoint 2007 there are two types of properties – crawled and managed. Crawled properties are automatically extracted from crawled content, but users can however only perform queries over managed properties. Thankfully Sharepoint lets us map one or more crawled properties onto a managed property and then, after the next crawl, those properties become available.
That description – one or more – is quite important as it permits an element of ‘fuzzy searching’ whereby the metadata category which the user wants to search on may be implemented in a number of different ways across different content types. This lets us hide that from the user.
The place to start is Central Admin – Shared Services Administration – Metadata Poperty Mappings. This is where you can check whether the properties you want are already being managed, or whether you will need to add them. For my list above, the “Created By”, “Created Date” [aka “created”], “Title” [aka “DisplayTitle] and “Modified By” properties are present but the “Contributor”, “Disposal Action”, “Disposal Date”, “Disposal Review”, “Document Type”, “Relation”, Topic and “Checked Out To” ones will need to be added. NB It may also be necessary to check the existing ones and add any additional new crawled properties to the list.
Adding them is really only a case of clicking the “new managed property” button, giving the property name (no embedded spaces allowed), a description, a type (text, integer, date, etc) and then deciding which crawled property (or properties) to map to.
In my case I’m mapping as follows
| Managed Property | Type | Crawled Properties |
| CreatedBy | Text | Creator |
| Created | Date/Time | Office:12 Basic:15 |
| DisplayTitle | Text | Basic:displaytitle |
| ModifiedBy | Text | ows_ModifiedBy ows_Modified_0x0020_By |
| Contributor | Text | _Contributor |
| DisposalAction | Text | Disposal Action ows_Disposal_x0020_Action |
| DisposalDate | Date/Time | ows_Disposal_x0020_Date |
| DisposalReview | Date/Time | Disposal Review |
| DocumentType | Text | Document Type ows_Document_x0020_Type |
| Relation | Text | _Relation |
| Topic | Text | ows_Topic Topic |
| CheckedOutTo | Text | ows_CheckoutUser |
At this point it would be nice if they all just magically appeared in the advanced search dropdown list, but unfortunatley there’s one more step involving evil editing of config files.
Go into your Advanced Search page and select Site Actions – Edit Page. For the Advanced Search Box webpart chose Edit- Modify Shared Webpart. In the “Properties” section there is a ‘properties’ dialogue box which, if you click into it, will give you the […] ‘builder’ link allowing you to edit the XML string.
This string has four sections, two of which concern us. Between <LangDefs> and </LangDefs> it lists all the languages which can be used and between <Languages> and </Languages> it causes those languages to be displayed in the web part.
We’re interested in the bottom two sections however. Somewhere between <PropertyDefs> and </PropertyDefs> we need to insert all of the Managed Properties we added above, following the format of the entries already there. So, for example, for our “DisplayTitle” property, we add the line
<PropertyDef Name=”DisplayTitle” DataType=”text” DisplayName=”Title”/>
Finally, in the section between <ResultTypes> and </ResultTypes> we need to show which result types we want our results to show up in. So assuming we want our new results to show up everywhere, we find the subsection between <ResultType DisplayName=”All Results” Name=”default”> and </ResultType> and add in the line
<PropertyRef Name=”DisplayTitle” />
Exit the “modify web part” process and publish the page if necessary.