How to: search the contents of a document set
Posted
Wednesday, November 9, 2011 4:03 PM
by
CoreyRoth
I saw this question in the forums the other day, so I decided to see if it is possible to use SharePoint search to query just the contents of a document set. It turns out that you can and it is quite easy. Consider the following document set. It has a number of contracts in it.
I want to be able to search the content of the document set. Document Sets are really just fancy folders. You can tell this by examining the URL when you are viewing one. Since it is just a folder, I realized that we can make use of the Site keyword that I have talked about before. Simply provide the URL and you will return all of the results of the document set. Here is an example. I can return the entire contents of the document set like in this example.
site:"http://sp2010/RM Test/Work Package 1/"
In the above example, my server is sp2010, the document library is RM Test and the document set is named Work Package 1. Here are the search results. Note, that it returns the documents in the document set as well as the welcome page.
Of course we can combine this with other terms. For example if I want to search for documents in this set that involve the state of Texas, I would issue the following query.
site:"http://sp2010/RM Test/Work Package 1/" Texas
As you can see querying the document set is easy. Now your users might not be able to create a query like that very easily, but as a developer it gives you something to work with. To search within large document sets, you could add a custom SearchBoxEx web part to the welcome page. The reason you would have to customize it is because you need the site keyword to pass in the URL of the document set. This could be done by inheriting from SearchBoxEx and by adding some simple code to get the current URL. I’ll look at building this web part in the future when I have more time. In the meantime, if you build one, drop me a line and tell me about it.