SharePoint is a great tool for managing files, documents, and anything else you can put into a list, but if you aren’t careful you could end up with unmanageable lists and libraries (especially if documents are added frequently). One solution is to use views with different filters and groupings, or to split your data across different folders. Then the problem changes, if you don’t have all the details you need to traverse through the tree of views and folders you will have a very hard time finding documents.
This is where SharePoint search crawls onto the stage. It is incredibly easy to get the SP search crawler to index your custom columns, and very simple to add them to an advanced search box. SP search is very scalable; adding more items just means it takes longer to perform a full crawl. On the other hand, views are limited to the View Threshold Limit (default is 5,000 items), and it is not suggested to increase that number too much. So it makes a lot of sense to utilize the search service especially if you plan for your document libraries to grow beyond 10,000 items.
Now for the fun stuff…
Adding Custom Columns as Searchable Properties
- Login to Central Admin
- Application Management -> Manage service applications
- Click on your Search Service
- Under Queries and Results click Metadata Properties
You should see something like the following:
This is where you can manage the SP software searchable properties. Also note that new properties will not be searchable until after a full crawl is performed.
- Give it a meaningful Property Name; this will be used in search queries and results
- Also a good idea to put details in the Description text field
- Select the data type
- Add the column mapping(s)
Mappings to crawled Properties section is where you actually define what columns map to this searchable property. You can define one or more columns; if you define multiple you have two options on how you want those values to be treated. You can include all of the properties, or you can include only the first one it finds based on the order in which you define them.
Mapping multiple columns to a single property is a great way of consolidating columns from different content types to a single searchable field. Suppose you have several content types each with their own cost column (Fuel Cost, Materials Cost, Project Cost, Insurance Cost); you could map all of these columns to a single searchable property, Cost. This would allow someone in the financial department to search all documents in SP software and only specify a single filter if they want to search by cost.
You select columns via their internal SharePoint name; some of these names are more cryptic than others. “Created By” is simply, Author, a custom column like “Project Name” might look something like “Project_x0020_Name”. A promoted InfoPath column on the other hand will be slightly more cryptic, _x0033_5d06fe7_x002d_ae68_x002d_454d_x002d_936a_x002d_b7821b271721.
2 easy ways to get the internal name of a column:
- Sort by the column in the List view.
- Edit the column in List/Library settings
After the page loads the URL will contain the internal name of the column.
After SP software completes a full crawl, your new properties will be searchable.
Configuring an Advanced Search Box with other Properties
- Create a new SharePoint page (or modify an existing page)
- Add an Advanced Search Box web part to the page
- Click Edit Web Part
- Expand the Properties section
- Copy/paste the Properties textbox to your favorite text editor
- You should see something like the following:
<PropertyDef Name=”Created” DataType=”datetime” DisplayName=”Created”/>
<PropertyDef Name=”CreatedBy” DataType=”text” DisplayName=”Created By”/>
<PropertyDef Name=”ModifiedBy” DataType=”text” DisplayName=”Last Modified By”/>
<ResultType DisplayName=”All Results” Name=”default”>
<PropertyRef Name=”Created” />
<PropertyRef Name=”CreatedBy” />
<PropertyRef Name=”ModifiedBy” />
The Parts of PropertyDef
- Name: The crawled property name
- DataType: text, integer, decimal, datetime, or yesno.
- DisplayName: What you want users to see in the dropdown selection
Simply add a PropertyDef for each property you would like your users to be able to filter by, and add the corresponding PropertyRef to the ResultType. After that is done you have done all you need to do to search and filter by any column you want within SP.
The next thing you’ll want to do is to surface custom properties within the search results, but that is out of scope for this article. In short, you would need to add a Search Core Results web part to a page (or the same page as the search box), and add your properties to the XSL of the results.