SharePoint: Search Lists and Document Libraries by Metadata
Guest Author: Peter Allen
BitsOfSharePoint
A while back I create a solution that would filter a list by the metadata, but would only do this for items and metadata viewable in the current list view. Here are the original articles:
- jQuery – List and Document Library Search Solution in SharePoint
- jQuery – List and Document Library Filter Version 2.0 – Part 2
Thanks to all the good feedback and suggestions I have created another solution that will allow you to search any list by its metadata and will search ALL items visible or not. Another feature I have added into this solution is that it can be placed on any pages and when the person searches it will taken them to results page.
In order to do this we will need to have access to SharePoint designer and have permissions to edit with SharePoint designer. SharePoint designer will be used to create a Data View Web Part where results will be displayed.
There are two main steps to create this search.
- Create a Search Results page.
- Add the Search Web Part to any page.
Let’s go over the process of creating a search page.
Create a Web Part Page.
Next edit it in SharePoint Designer.
Now add a Data View Web Part to a Web Part Zone. To do this you will need to select the list or library from the Data Source Library. The list or library you choose will be the one that is search with this solution.

Then select what the columns want to show. Also add them as a Multiple Item View.

When you save the file you will get a warning, don’t worry go ahead and say yes.

Next you will customize how the list is filtered.

Choose what fields you will filter on or have the search look through.

For the comparison make sure you select contains so that it is not an exact match.

Next for Value you are going to select Create a New Parameter.

Complete the parameter with the following:
- Name: Search
- Parameter Source: Query String (this is how it looks at the URL for the search criteria)
- Query String Variable: Search

For each field/column that you want to search add another to the list and make sure the And/Or is set to Or.

When you click OK your list of items will disappear, but that is OK and is expected.

You are now done with the first major part. If you want to customize the list more, feel free to do so. To customize the Data View web part that has nothing showing just check the box under “Common Data View Tasks” called “Show with sample data”.
The last part is to load the Search Web Part. This web part is one that I created and will need to be downloaded placed on any page of your SharePoint site. I would add this to the Search Results page as well.
Search_List: http://www.bitsofsharepoint.com/ExamplePoint/CodeExamples/Search_List.dwp
Next edit the Web Part with the Rich Text Editor and change the following:
- Search Results Location: This should be the full URL of where the Search Results page you created with the Data View Web Part is.
- Search Box Location: Designate if it will be on the left, center or right.
- Search Title: Name your search so that your end users know what they are searching.

Then save the changes and you should be able to search your list and view the results.
Here you can find a working example: List and Document Library Search
Guest Author: Peter Allen
BitsOfSharePoint
Peter Allen is President of BitsOfSharePoint Consulting LLC, based in Sacramento, CA. He has worked in the technology field for 15 years creating and deploying solutions in Healthcare, financial, construction, municipalities, telecom, and engineering firms. He provides solutions that address site architecture, taxonomy, useability and findability. He also speaks at SharePoint community events and blogs at his SharePoint site http://www.bitsofsharepoint.com.
Thanks for the filtering solution but can this filter with items more than 100 items in a list view.
Understand that Sharepoint got this limitation to only display 1-100 items in a list and the filter only take care of this 100 items within this view.
Any solution to filter through all the items.
Francis,
Yes, this solution will filter/search the whole list not just the 100 being viewed. My first solution, which I mentioned at the beginning of the article, only filtered what you were seeing.
You should be able to follow the steps above, in this article, and have a solution that searches the whole list.
Thanks for sharing but as I am new to sharepoint, I get stucked when I come to “The last part is to load the Search Web Part. This web part is one that I created and will need to be downloaded placed on any page of your SharePoint site. I would add this to the Search Results page as well.”
Could you clarify the statement?
Sam,
After you have edit the page in Designer, now open the page in IE so that you can edit and add the Web Part I created. The link is in the article.
First download the web part to your hard drive, then edit the search page in IE and do an import a web part and load the web part you downloaded onto your computer.
Once you add the web part I provided and configure it you can then do a search.
Hope that helps.
Thanks a lot but I am still have some confustion. The web part page that we edit in the SharePoint Designer is the search page, right? But I have no ideas on how to load the web part to the search page. I opened it in IE, click ‘edit page’ and ‘add a web part’. I cannot find any places for me to place/ import your web part.
Thanks and look forward to your explaination :)
Follow this link and review the steps to importing a web part. This should help you in how to do this.
http://community.bamboosolutions.com/blogs/sharepoint_blank/archive/2009/01/08/how-to-export-amp-import-web-parts-in-sharepoint.aspx
Can this be modified to search more then one list? Like maybe 4 lists in the same site.
Yes, I have done this for a client and it works well. Just follow the setups and apply it to the three other lists you add to the page. You will only need one Search Web Part to make it work.
Thanks and I finally get to the search for 1 list. I wonder where can I put the remaining lists in as I failed to group them into 1 list for search.
You have been helpful, Thank you very much!
Oh I am able to search different lists by merging different lists into 1 big list now! But the list of items do not disappear. What should I do?
You would have 4 separate lists and would follow the same steps I outlined for each list. You should not have to combine them. Just adding the three other lists does not make them searchable. You have to add the list filter parameter to each one.
I get your point and I can work them out now. However, I need to insert them into differnt ‘insert web part areas’. Anyway, I would not have done this without your help, thank you very much!
Sam,
Can you explain me how it’s working for you, ‘coz i am having problem with this.
i am trying to filtering and searching on document library.
which is the best webpart for me to download ‘coz there is too many with different versions.
help me.
I’m having two issues with your solution as well. First, I’m getting an SSL warning each time I open the page with the Search_List webpart (I presume from the js bit). Any help on getting Sharepoint to accept that web part?
Second, the search result is always blank. I had to do more than use only the Rich Text Editor for the web part you provided as it was still trying to reference your bitsofsharepoint.com site until I changed the URL within the Source Editor. I’m fairly new to Sharepoint Designer, but I feel like I followed the steps best possible.
Chris,
Issue One: Not sure what the SSL issue would be. Are you access it with https://?
Issue Two: By default the search page will be blank until you make a search. Just part of the way SP works with Data View Web Part when you are filtering based on a query string. Since it is blank to start with, it finds nothing and shows nothing. Once you put a search variable in it, it will show results.
1 – I am accessing it via https:// (we also have a redirect setup in case the user only does http://)
2 – I have tried using the search. I added the piece you provided to the main page of the site, modified it to point to the Data View Web Part that you walked us through creating, but even with a search string in the search box it’s still coming up empty.
IE browsers will pop up a security warning when content from an external source is being pulled into the page. Peter, is there something in the solutions that is pointing to an external script? — Mark
Yes, jQuery. You can make it local if you like.
hi
i created webpart page. attached it with document lib, as you shown
Now i download search webpart and import it on same page where i configure data view (webpart page which i created and customize in sharepoint designer) , now when i am going to edit search webpart by Rich Text Editior it shows me a
Filter Box location
value
Help
Options
value
Help
But not Showing Like You Show in example so, where i have to put URL of search result page?
Comment
It looks like you are mixing up my two solutions for Search or Filtering a list. You are using a web part designed for the filter solution, when you should be using the web part for the search solution. It can be found here: http://www.bitsofsharepoint.com/ExamplePoint/CodeExamples/Search_List.dwp
Hi Pete
you are life saver!!!! I have been pulling my hair to implement search option on Sharepoint list. Your solution worked perfect for me. When I see its working…..WOW!!!!!!
Thanks a million
Siva
Hi, I’m looking at creating a custom search page and came across this article. With my current site we’ve seen a degredation of time to load a page due to jquery. (We use it for parent child functionality). Are there any speed concerns using this solutiion?
Hard to say with out know your environment. The jQuery solution here is very light. The main drain on resources will be from SP filtering the list. The larger the list the more load.
Best to test this out and see what loads you get.
Thanks so much Peter, I implemeted your search guide and it has helped me so much in searching our document library.
I have another question:
How can I search by a date range or a date field
How can I use a wildcard in the search guide you gave us
Regards,
Emmana
These are great questions and requests, but are a limitation of this solution. This is a simple solution to look for content that matches. I would suggest looking for a third party add on to meet your needs.
Hello Peter,
How can I export the result of the search to another format like Excel, or CSV
Regards,
Emmana
Again this is not part of this solution. A third party solution would be able to do this for you.
Good, can you give me the names of the third solutions and how I can locate them.
Again, am I to instal the third party application on the server?
Emmana
Hi
Thank you for a great solution!
Is it possible to…
1. Enable the edit link for the dokuments in the serach results? (as in the arrow in “normal” doc library when holding over the dokument link)
2. By default show all documents when loading the search page, and then make the search to narrow down the results?
Thank you.
Hi
I wonder what´s the difference from your search webpart and the standard SP searchwebpart?
I have used both and cannot spot any differences, so please enlighten me ;-)
Thanks in advance.
/Michael
I had a similer type of solution that I discovered way back.
URL: http://mysplist.blogspot.com/2009/05/implementing-search-in-sharepoint-list.html
Peter,
Awesome solution, worked perfectly for me. One question though: Would it be possible (and if so, how?) to input the search term back into the text box when the user searches for a particular term.
As it is, when a user submits any search, the results appear, but the only way for them to see exactly what they searched for is to look at the query string in the URL. Is there any way to put that term back in the search box when the page loads the search results?
Thank you for a great solution.
Ruth,
I have updated the solution with you request. It now keeps the search term in the search box after a search.
Peter
Peter,
Awesome! Your fix worked perfectly. Thanks for the quick response!
Peter: Awesome solution!
I’m able to get the solution to work on a DEWP when it is from a single source but then I took it a step further and created a linked source based on multiple document libraries.
When the filter criteria is added it makes no difference to the web part, it continue to show all results
When the Search DWP is added, it produces a blank result. Any assistance and guidance will be greatly appreciated.
I tested a few conditions and may have narrowed down on the problem. The issue is that of not having case insensitiveness in XPATH.