Custom Software Apps & SharePoint Consulting

Save users valuable time with custom SharePoint Search

Matthew McDermott, a Microsoft SharePoint MVP, believes that every hour a developer dedicates to working on search saves 100 hours of end-user time.

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

  1. Login to Central Admin
  2. Application Management -> Manage service applications
  3. Click on your Search Service
  4. 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.

  1. Give it a meaningful Property Name; this will be used in search queries and results
  2. Also a good idea to put details in the Description text field
  3. Select the data type
  4. 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:

  1. Sort by the column in the List view.

Or

  1. Edit the column in List/Library settings

After the page loads the URL will contain the internal name of the column.

..SortField=_x0033_5d06fe7_x002d_ae68_x002d_454d_x002d_936a_x002d_b7821b271721&SortDir=Asc

… {96DC46B1-7316-449F-B719-D64F604BB633}&Field=Project_x0020_Name

After SP software completes a full crawl, your new properties will be searchable.

 

Configuring an Advanced Search Box with other Properties

  1. Create a new SharePoint page (or modify an existing page)
  2. Add an Advanced Search Box web part to the page
  3. Click Edit Web Part
  4. Expand the Properties section
  5. Copy/paste the Properties textbox to your favorite text editor
  6. You should see something like the following:

<root xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>

<PropertyDefs>

<PropertyDef Name=”Created” DataType=”datetime” DisplayName=”Created”/>

<PropertyDef Name=”CreatedBy” DataType=”text” DisplayName=”Created By”/>

<PropertyDef Name=”ModifiedBy” DataType=”text” DisplayName=”Last Modified By”/>

</PropertyDefs>

<ResultTypes>

<ResultType DisplayName=”All Results” Name=”default”>

<KeywordQuery/>

<PropertyRef Name=”Created” />

<PropertyRef Name=”CreatedBy” />

<PropertyRef Name=”ModifiedBy” />

</ResultType>

</ResultTypes>

</root>

 

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.

Share this post with your friends

Skip to content