B i t s O f S h a r e P o i n t C o n s u l t i n g L L C > B l o g P o i n t > Posts > Search Lists and Document Libraries by Metadata
Search Lists and Document Libraries by Metadata

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:

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.

  1. Create a Search Results page.
  2. 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.

image

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

image

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

image

Next you will customize how the list is filtered.

image

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

image

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

image

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

image

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

image

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

image

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

image

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.

image

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

Comments

Thank you for your contributions to SharePoint developers

The list/doc library filter/search, through jQuery in a CEWP, is a great tool and quite elegant compared to the few out of date options for similiar functionality that are out on the web.  The tutorial on how to get this done is really appreciated.
at 6/11/2010 5:18 PM

wow

brilliant stuff mate!
at 10/21/2010 12:27 PM

Search lists by metadata -- how to use in SharePoint 2010

Peter, have you written anything on how to user this solution in SharePoint 2010? 

I use the HTML Form Web Part for inserting jQuery code in SP2010 because the CEWP messes with my code. However, the HTML Form web part doesn't have a rich text editor, so your beautiful wrapping of the code to allow a dummy like me to use it doesn't work. 

I'll experiment with pulling out just the code needed to make the solution work, but wondered if you have already taught us how to do that?  I'll keep hunting.
at 7/21/2011 12:26 PM

RE: Search lists by metadata -- how to use in SharePoint 2010

I hear you on 2010.  I have been very busy with clients and implementation that I have not been working on 2010 solutions.  I am hoping to be doing some work soon on solutions for 2010.  First is the Global Navigation solution.
Peter Allen at 8/16/2011 11:18 AM

Without Designer?

Peter- really well done, this is an excellent and elegant solution. I'm wondering, is it possible to achieve this solution without the use of SPD? I don't have access to SPD for the particular site I'm designing and was hoping there would be a way around it.

I've looked into the earlier version of this solution, which also works well, but I fear for lag time since primary list used will likely contain 1000+ items.

Any thoughts you can offer would be appreciated!
at 1/12/2012 1:47 PM

Re: Without Designer?

You will need SPD for this solution, sorry.  Yes I agree that having a 1000 items in a view could have performace issues, but I try and see how it goes.
Peter Allen at 1/15/2012 11:45 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Addition: 2 + 1 = *


Please complete this equation.

Email


This is optional.
Attachments

 T o p i c P o i n t

 E x a m p l e P o i n t