Force File Name in SharePoint 2010 Search Results

There are a few resources on this for 2007, but I thought I’d add a small update for 2010.

First, start by following the instructions in the links above for the IsDocument property.  You can get to it from the search service administration and it’s under Metadata Properties:

Find the IsDocument property in here

Now go to your site and create a new web part page (header, left nav, right body) and call it CustomSearchResults.aspx (or whatever you’d like).  On the right hand side, add a ” web part and on the left hand side, add a Refinement Panel web part.

Search web parts available - add Search Core Results and Refinement Panel

Now you need to edit the results web part.

  1. Under the Core Results settings panel, expand the Display Properties sub-panel.
  2. Uncheck Use Location Visualization to enable the Fetched Properties and XSL Editor options.
  3. Modify the Fetched Properties XML string to include <Column Name=”Filename”/> (strongly recommend copying the string out and editing it in a text editor).
  4. Click the XSL Editor button to modify the XSL.  Again, I strongly recommend copying the XSL out to a text editor.
  5. Around line 206-207, you should see the following line:
  6. Modify it to look like so:
  7. Next, around (new) line 324, you should see the following XSL:
  8. Update this to the following:

Now hook up your custom search results page by clicking on Site Settings and then Search Settings. In the Site Collection Search Results Page text box, enter the full relative path to your page (including sub-site paths and such).  For example: /sites/site_xyz/pages/mycustomsearchresults.aspx.

That should do it.  Unfortunately, I haven’t figured out how to turn on hit highlighting for the file name yet.

You may also like...