Searching Content Types in MOSS 2007
Posted
Tuesday, February 05, 2008 6:49 PM
by
Itay Shakury
If you ever tried to use SharePoint's Content Types with search, you'll find it simply doesn't work. This article tries to help you overcome this issue.
In the following article
- I use the term 'IMT' to address the Internet Media Type (AKA MIME type) of the file (text/plain, application/vnd.ms-word, image/gif, etc...).
- I use the term 'SP Content Type' for a SharePoint content type (Item, Event, Document, etc...).
- I use the MOSS Query Tool to quickly execute search queries against MOSS.
Example:
We have created a SP Content Type called 'Article'. We then want to search our site for all documents of the 'Article' content type. We find no results.
Problem:
As we can see at picture above, the built-in managed property 'ContentType' usually gets populated with values that represents the Internet Media Type of the file, instead of the desirable SharePoint Content type.
Cause:
If we take a look at the built-in 'ContentType' managed property, we find out that it first gets the IMT of the file, and only then the SP CT of the file. In this case, the SP CT will be picked into the property only if there is not an IMT for the file.
We also find out that unlike any other managed properties, we can't edit the crawled properties here, nor change the order they are picked.
Solution:
Create a new managed property, that contains the same properties, but in the opposite order. This way, the gatherer will first look for a SP CT, and only if it doesn't exists, it will pick the IMT of the file.
1. Go to SSP Management --> Search settings --> Metadata property mappings --> New managed property.
2. Type a name in the 'Property name' field.
3. Select the second radio button - 'Include values from a single crawled property based on the order specified'.
4. Click the 'Add mapping' button.
(Click to enlarge)
4. Search for and add the property 'ows_ContentType' (under the 'SharePoint' category)
(Click to enlarge)
5. Search for and add the property 'Basic:5' (under the 'basic' category)
6. Click on 'OK'
7. Recrawl your content.
Result:
You have a managed property that contains the SharePoint Content Type of items. You can use this managed property in search.
