Searching Custom Column Values in MOSS 2007
An issue that came up on a recent project was how can we search custom meta-data on document libraries in MOSS 2007? So for instance, let’s say that in a set of document libraries in a site or across a number of sites each will have a custom column named “Department” that is of a data type “Choice” and the possible values are each department in an organization. Now let’s say that end-users would like to use advanced search to use the Department field as search criteria.
I knew this was possible with SPS 2003, however, I sadly never had a chance or a reason to try it out – but now I did with SharePoint 2007, yippee! So in order to figure this out, I did a cursory search online and hit TechNet’s MOSS section, but alas, I could not find anything showing exactly what I was looking for. So through some brainstorming with a colleague and also some trial and error I was able to get it.
First off, let's create a custom column of type "Choice" in a sample document library. I've named mine "Department" and given it three possible value options ("Sales", "IT", "Marketing").
Now that we have our column created, we need to run a full crawl in the Shared Service Provider (SSP) to make SharePoint aware of this new piece of meta-data. After the crawl is run, our new property will be captured as (what in SharePoint parlance is called) a "Crawled Property", however that is not enough to perform searching on it, we need to also then create a separate "Managed Property" and map the crawled property to the manually created Managed Property (also as a side note, you can map more than one crawled property to a managed property). Once we do this, SharePoint will be fully aware of the property's existence and we can use it as search criteria. The steps for all of this are below:
In the "Properties" text box under the "Properties" section is the XML defining which properties are searchable when which "Result type" option is selected (such as "Word Documents" or "Excel Documents"). We need to update this XML snippet with the correct nodes to define our new "Department" meta-data. Copy and paste the XML into your favorite text editor and make the following updates:

I knew this was possible with SPS 2003, however, I sadly never had a chance or a reason to try it out – but now I did with SharePoint 2007, yippee! So in order to figure this out, I did a cursory search online and hit TechNet’s MOSS section, but alas, I could not find anything showing exactly what I was looking for. So through some brainstorming with a colleague and also some trial and error I was able to get it.
First off, let's create a custom column of type "Choice" in a sample document library. I've named mine "Department" and given it three possible value options ("Sales", "IT", "Marketing").
Now that we have our column created, we need to run a full crawl in the Shared Service Provider (SSP) to make SharePoint aware of this new piece of meta-data. After the crawl is run, our new property will be captured as (what in SharePoint parlance is called) a "Crawled Property", however that is not enough to perform searching on it, we need to also then create a separate "Managed Property" and map the crawled property to the manually created Managed Property (also as a side note, you can map more than one crawled property to a managed property). Once we do this, SharePoint will be fully aware of the property's existence and we can use it as search criteria. The steps for all of this are below:
- Open up the admin page to the SSP that is hosting the web application your document library is sitting in
- Click on “Search Setting”, then “Content sources and crawl schedules”
- Find the content source that contains your site and perform a full crawl on it
Now SharePoint is aware our your new piece of meta-data and we can create a "Managed Property" to map to it. - Go back to the "Search Settings" page for your SSP and click "Metadata property mappings"
- On the "Metadata Property Mappings" page click the "New Managed Property" link

- Give a name for the managed property (I chose "OrgDepartment" to make it unique).
- Select the correct data type, in this case "Text"
- Now in the "Mappings to crawled properties" section of the form, click "Add Mapping" to bring up the crawled property selection dialog
- This is a cool little widget in that you can actually search for the property you are looking for, in this case "Department". So enter "Department" in the "Crawled property name" text box and click "Find"
- In the results I found one named "Department(Text)" and chose that. Now this is something I am still not completely clear on because also in the results list was a crawled property named "ows_Department(Text)" and I am not sure which one is best to use, but I can say that choosing the one without the "ows_" prefix worked just fine. Maybe when better documentation comes out I can get to the bottom of this!
- Once that we have this form filled out, click OK and perform another full crawl on the necessary content source
- Once that we have this form filled out, click OK then go back to the "Manage Content Sources" page and perform another full crawl on the necessary content source
- Go to a search center site and click "Advanced Search"
- Click on "Site Actions" then "Edit Page"
- In the "Advanced Search Box" click "Edit" on the top right then click "Modify Shared Web Part"
- On the pane to the right expand the "Properties" section
In the "Properties" text box under the "Properties" section is the XML defining which properties are searchable when which "Result type" option is selected (such as "Word Documents" or "Excel Documents"). We need to update this XML snippet with the correct nodes to define our new "Department" meta-data. Copy and paste the XML into your favorite text editor and make the following updates:
- In the <PropertyDefs> node add the following line:
<PropertyDef Name="OrgDepartment" DataType="text" DisplayName="Department" />
This now adds a definition for our managed property into the search page, however, we will still need to add one more node to make it searchable on the page. The "Name" attribute must match up to the name of the managed property we created earlier and whatever is in the "DisplayName" attribute will be shown in the drop-down list on the UI of the advanced search page. - In one of the <ResultType> nodes (it is your choice, each ResultType node points to a different document type or overarches across all or a set of document types.) add the following node:
<PropertyRef Name="OrgDepartment" />
At this point you just need to exit edit mode and refresh the page and -kapow!- your new piece of meta-data is available in advanced search as search criteria!

Labels: Advanced Search, Enterprise Search, Meta Data, Search, SharePoint, Taxonomy, WSS


41 Comments:
Patrick here.. there is no reason why you need to index the column. Indexing columns is only for increasing the performance when doing CAML queries
How interesting, thanks Patrick!
I was wondering about that, but left that step in there "just to be safe". I will update the entry!
Great detailed article. After adding the column, I did a full crawl, and it doesn't show up as a managed property. Any suggestions?
Hi Jeff,
Sorry for the delay in getting back to you, I was in Tombstone, AZ of all places when you posted your reply!
After you run a crawl after creating the custom column the indexer create a "crawled property" but you will actually need to manually create a "managed property" which you can then map to the crawled property that was "discovered" via the crawl.
Hi,
good walkthrough, but one thing is missing : in the advanced search, I would like the possible values for 'Departments' listed in a dropdown box.
Is this possible?
Thanx for this great article. One other question: is it pssible to use a filled list of values?
i.e.: custom property is department and city
and there are only "IT" and "SALES" for department as answer values possible and "NY" and "Washington" for the city-property.. I want to implement the value as list minimizing user-failures.
Great article, Jonathon.
Any answer regarding Steven qustion for 'Departments' listed in a dropdown box?
Thanks for article, Jonathon.
But is there a posibility to add managed property programatically (throw API) ?
can we have a three choises i.e sales.It,marketing in Advance search if so how can we implement that if not is any other way we can search based on choises
I have a problem at the stage of adding the XML PropertyDefs and Refs - they are added fine, but nothing shows up in the drop down menus where you say they are supposed to show. Any idea where it could be going wrong?
Thanks for the Article Jon!
One question: What if the columns do not show up under the Metadata Property settings? I've checked that the default access account has access, the Crawl log doesn't report and any errors on the site and I've tried creating Site Content Columns. But I'm not sure why the meta data is still not showing up not allowing me to create a new mapping.
Any suggestions???
Hi,
I have followed all the steps which you mentioned.But still the search result is empty.
Any suggestion?
Any answer regarding Steven qustion for 'Departments' listed in a dropdown box?
any response to the commet that steven made?
Very good article.
By the way, may I raise one question? Our clients request one thing that they wants to search depends on customized attributes only. And they want to categorize the result depends on criteria. For example, Music, Movie, Picture
They also want to know how many results for Music, Movie,Picture.
I am not sure it can be with Advance Search or not. It can be? I am new one for sharepoint development. Can you give me any suggestion? I have to give answers back in short days.
Hey Jon,
Kool article. Thanx. U explained everything very well.
Reply to greeting: Sorry for the delay on this, I moved recently from Seattle to Phoenix. Regarding your question, yes, it is possible to change how the search results render -- on a results page, you can edit the core results web part and edit the XSLT that processes the results. If you are a wiz at XSLT you can modify it to group the results by a column (and show totals I would assume). Also, I think on Steven Van de Craen's Blog he has an entry on how to use SharePoint Designer as a helper to generate XSLT for the search results page.
Back at Steven et al.: Good question! I am still not sure how to show a "prescribed" list of possible search values. I am currently on a project where that would be a nice to have. There might be a way, but it may involve some crazy hackish stuff. As soon as I find this out I will be sure to post a part II to my article!
Really nice and helpful article :)
Nevertheless, I still don't success for listing values in a dropdown box :S
If u could help me with that, it will be nice ! :D
PS : Scuse my bad grammar, i'm not enlgish....
Hi there
thanks for the nice walk-through. You mentioned you weren't quite sure about the meaning of the ows_ properties. My understanding is that the ows_ properties are the properties that come from Office documents.
greetings, Bruno
I've been searching around for ways to enable comparison operators such as >,>=,<,<= for managed properties. Any ideas? Thanks in advance
Excellent details on this one. I'm also after the dropdowns in the choice of criteria, so if anyone finds a solution to this it would be excellent.
Hopefully, answering my own question, or at least getting nearer to a solution.
Tom Clarkson has a very good article here on create a custom advanced search box:
http://www.tqcblog.com/archive/2007/10/25/creating-a-custom-advanced-search-box-in-moss-2007.aspx
Hope this helps previous commenters.
I have a weird problem though .. I dont see a ellipsis button next to the properties textbox in the webpart editor .. so cant change the xml to add new property defs.. any ideas?
I recently found why I wasn't able to find my site column in the managed property. It was because my site column wasn't used. The crawling seems to ignore the unused site column.
I recently found why I wasn't able to find my site column in the managed property. It was because my site column wasn't used. The crawling seems to ignore the unused site column.
I recently found why I wasn't able to find my site column in the managed property. It was because my site column wasn't used. The crawling seems to ignore the unused site column.
I recently found why I wasn't able to find my site column in the managed property. It was because my site column wasn't used. The crawling seems to ignore the unused site column.
Jonathon,
Nice article. Thanks. I've followed all the steps. I believe I've set up everything correctly. My properties appear in the Advanced Search dropdown. But whenever I use any of my custom metadata in a search, it returns no results.
Any suggestions for what I might have done wrong, or where to look for reasons for the failure?
Thanks,
Adam.
This post has been removed by the author.
Thanks for the great info, Jonathon. I used your guide to setup some custom columns so they could show up in the Faceted Search.
`Andy
Thanks for this article, Jonathon. For some reason I'm having the same problem as Adam Rose above. I've followed all the steps and the metadata shows up in the dropdown, but the search doesn't show any results when I use the new metadata. The search works good with the old metadata.
Ideas what might be wrong, anyone?
Great guide!
I used it, and it worked...partially
My problem was that Office 2007 documents didnt show up in a search, Office 2003 worked fine.
The problem was that i did not use the "ows_" property in the managed property section.
When i selected "ows_" and did a crawl again it worked flawlessly
So I guess thats one of the differences between these tags...
I am having a problem that seems to be common. I have several custom columns, but none of them are showing up when I try to create the managed property.
It seems that they are not being added as crawled properties. Any idea why this may be?
Found the problem.
Looks like one of the search processes was not set up for the account to have local activation rights.
What exactly do you mean with this:
"Looks like one of the search processes was not set up for the account to have local activation rights."
What process and where exactly? I need more detailed steps to check this possible problem issue.
When I define my custom column for "SitesList" list then column is NOT crawled at all. Great! Somehow MOSS decides to leave it out when custom column is added in this certain type of list (SitesList).
Adding same custom column e.g. to Document Library makes it show up correctly as crawled property.
Hi,
I had followed all the steps specified in the article but unable to get the custom columns(managed properties) in drop down list of the Advance Search web part. previously I was able but, since I formated my server and installed SP1 for MOSS, I am not getting them. Also while creating the managed properties I am getting column name as "ows_column name" and not directly the "column Name".
Any suggestion will be appreciated.
Thanks.
Good post Jonathan...
I implemented the above procedure to create custom properties. I could create custom properties and am able search again 'Text' datatypes successfully. However, the ones with 'Decimal' datatype are posing problems. When I search using 'Equals' or 'Does not equal to', it throws a service error, with no search results. 'Greater than' and 'Less than' conditions are working well though.
Any ideas into why this could be happening?
Thanks in advance.
Hi i am using sharepoint 2007 and in a custom list i have an ID field with data type number when i try to search any ID no result comes in front of me.
Can you help me to find the ID and i don't want to change its data type from number to text.
Please guide me how to get results in search...
Hussain.
If the results are empty check that there is an entry under the result section as the article says and also run "Full Crawl". Running "Full Crawl" worked for me.
Post a Comment
Links to this post:
Create a Link
<< Home