The SPS search page – search.aspx – is actually a Web Part Page containing four Web Parts – Search Box, Search Results, Advanced Search, and Search Menu. Like other Web Parts these can be tweaked by setting various properties on them. But what properties can you set and how do you go about doing this?
 
Modifying the Search Page
Well it may not be obvious but you can modify the search.aspx in the same way that you can modify other Web Part Pages by appending ?mode=edit&pageview=shared to the URL. This allows you to go into design mode and modify those properties that are exposed through the user interface.
 
As an example you can add the OpenNewWindowForMatchingItems property to the .dwp and reimported the Web Part. The end result is a new window being opened when I click on the results of a search – a commonly asked for piece of functionality.  Some other interesting properties that you might like to investigate are as follows:
  • EnableSQLCommandLogging – Logs the full SQL query performed by searches to the IIS logfiles. Useful for analyzing the type of queries your users are doing.
  • ShowRankForEachItem – Shows the rank assigned to each search result
  • ColumnDisplayNames – Supports sortable column headings in search results

Exporting Search.dwp

  • Enter a search (i.e. "get me to the search page") and submit.
  • Append "?mode=edit&pageview=shared" just after .aspx and press Enter.
  • Click modify page.
  • Click the Search results webpart down arrow (upper right corner) and select export – for a location select your favourite directory.
  • Open the webpart in VS.Net and browse to the tag ResultLikstID.
  • Insert the following code and save the file.

<OpenNewWindowForMatchingItems xmlns="urn:schemas-microsoft-com:sharepoint:DataResultBase">true</OpenNewWindowForMatchingItems>
<ShowRankForEachItem xmlns="urn:schemas-microsoft-com:sharepoint:DataResultBase">true</ShowRankForEachItem>
<ColumnDisplayNames xmlns="urn:schemas-microsoft-com:sharepoint:DataResultBase">Title,Author,Date</ColumnDisplayNames>
<EnableSQLCommandLogging xmlns="urn:schemas-microsoft-com:sharepoint:DataResultBase">true</EnableSQLCommandLogging>

  • Import the WebPart and close the existing Search page.
  • Done.

Submit a new search and observe the results. Also, open your IIS logs and you will see the search query as well.

Enjoy!

 

Advertisements