Friday, August 12, 2011

SharePoint Search on a Specific Document Library/List

How can you use OOTB search to perform search on a single specific list? When you perform a search, it will search those areas depending upon your content source, which is never specific to a single library containing documents. How can you perform a search where it only pulls the data from this given document library? You could use a common document property and then map it to perform your search. However, this is not a very consistent approach as some users may forget to do so. Therefore, it is better to use a column to create this feature. An alternative approach is to simply use scopes!

The key concept here is a metadata property that needs to be used. In this document, I will very briefly walk you through the process and show you how this can be extended to N number of document libraries. The same process can easily be applied to a list.

1: Create a document library for some finance group that you want to have a specific search upon. If that library exists, create a new column and call it MySearchColumn with a default value (Finance) and make sure the column is marked as not required field. Better, create a site column and then use it in this list. I will come back to why I suggested a site column.

2. Next, Go to the advanced setting of the Library and click on Manage content types. Once you do that, you will see the option to hidden the MySearchColumn from the form. This is a neat trick to hide the extra irrelevant column from the user and still maintain consistency. You could have let this column be there and the user could have asked you several questions. You could have educated the user on why you have this column in its place. You could have also written an event handler to ensure the value is consistent.
3. Now try adding a new document to the library and the MySearchColumn is not displayed on EditForm.aspx. Note, it will be visible from the “All Documents” view, but you can change this once you have completed the task.
4. Go to Central Administration -> Search Service Application->Search Administration and do a crawl. The reason you have to do this is so that the newly added column will be displayed in the MetaDataProperty.
5. Now create a new Meta Data Property by giving it a name “MyMetaDataProperty” that is mapped to ows_MySearchColumn. You should see this ows_MySearchColumn when you go to AddMapping. If you don’t see the column then there is a problem with your crawler or field name.
6. Next create a “Basic Search Template” that will be used to perform the search. When this is created a basic search page gets displayed. Click on the “Advanced Search”. On this page, edit the “advanced search webpart” to include this new property that you have created in Search Administration. When you click edit webpart, it displays you properties of the web part you can change. Click on properties section to open the box and then copy the XML into an XML editor where you need to add simillar following lines


Then, you need also include in the results section


7. Once this is completed, you should see 1 more managed property. Now, start a full crawl from
“Search Admin” and not an incremental crawl as the data from the new property will not show up.

8. Go to Advance search and choose the new property from the drop down below and choose equals “Finance” and perform you search. You should see results coming from that 1 single document library.

9. Similarly, if you have more document libraries you can reuse the same site column, but with a different value. The advantage of this approach is that you don’t have to set another meta data property and just put different value and you can now search exclusively in a different document library.









1 comment:

  1. Is this for 2007? or 2010? I'm working on creating a DocLib that is searched on its own.

    ReplyDelete