|
Secrets of the SharePoint Search Results Revealed - Mauro Cardarelli
From a Microsoft perspective,
2004 was the year of SharePoint Portal Server. Organizations
around the world have implemented SharePoint-based solutions
for more effective knowledge management and better team collaboration.
It is becoming the single source for corporate content…
unless, of course, you are trying to find something! I’ve equated
the SharePoint search results with my seven year old daughter’s
room: I know what I’m looking for is in there somewhere;
I just can’t find it. This article is intended to help you
better leverage SharePoint’s search results… I’ve given up on my
daughter’s room.
Introduction
You’ve created a
portal site for your organization. You put documents in document
libraries, enabled discussions via discussion threads, and
implemented ifilters to include additional content like pdf’s. You
have configured SharePoint to crawl your file shares, public
folders, and external websites. All this content is searched as
part of your portal’s search interface. What a mess! Don’t get me
wrong; the search engine is great. It always finds the proper
results. Sometimes, I just have trouble understanding how to use
this data.
Although it isn't obvious, SharePoint
exposes a great deal of additional search flexibility behind its
standard search web part. Let’s look at how to find these
parameters.
Viewing SharePoint’s Search
Parameters
Follow these steps to export SharePoint’s search
parameters to an XML file.
(1) In your browser, go to the following path:
http:///search.aspx?mode=edit&view=shared
(2) You’ll see the context menu ‘Modify My
Page’; select ‘Shared View’
(3) You’ll see the context menu ‘Modify Shared
Page’; select ‘Design This Page’
(4) Your search page is now in design mode. On
the Search Results web part, click the down arrow and select
‘Export…’
(5) Save the file to your hard drive. It will
create a .dwp file (this is a web part file extension). The
contents are standard XML. You can make changes to this file. It
is strongly recommended that you save a copy of this original
file.
For the
Beginner
If you do nothing else with the search
parameter file, add the following line (you can place it above the
‘GroupbyList’ line):
<OpenNewWindowForMatchingItems
xmlns="urn:schemas-microsoft-com:sharepoint:DataResultBase">true</OpenNewWindowForMatchingItems>
This parameter
tells SharePoint to pop up a new window for each selected search
item. One of the frustrating behaviors of standard SharePoint
search results is that when you select a search item the results
are shown in the same window. You lose your connection to your
original search list. The only way back is the IE 'Back' button or
re-executing the search. The method above forces a new window. You
can look at the results, close the window, and return to your
search list. This has generated a few “Wow’s” in my
demonstrations.
For
the Bold
Ever wonder why
SharePoint always shows the top 40 results? It is a property in
the search results file called ‘MaxMatchingItemsNumber’. You can
change it by altering its value. The default sort is stored in
‘DefaultSortBy’. You can alter ‘ColumnURIs’ to control the header
associated with search results (i.e. you can remove Author, the
default middle column, and replace it with the content type).
I suggest that you spend some time and study the XML. It
offers some interesting insight into what SharePoint is doing with
its search results.
For the
Truly Brave
This section is
intended for those who are comfortable enough with SharePoint to
create more advanced search solutions.
I believe the .dwp file’s most
interesting method is the ‘QueryTemplateWherePart’. It contains
the logic that controls relevancy as well as scope. If you are
truly brave, you can alter the order of the search results as well
as limit scope to a specific portal region. As an example, my
portal’s search results page contains many results web parts. I
have one for just People; another searches technology topics only.
I’ve done this by creating unique search parameter files. Note,
this works naturally with the standard SharePoint search box… all
with no custom code!
Above, I showed how to add a method to
pop up search items in a new window. You may wonder what else is
‘missing’ from the standard search file. The list of available
methods is at:
http://msdn.microsoft.com/library/en-us/spptsdk/html/cDataResultBase.asp?frame=true
I found this list in my investigation
and have actually used a few methods. One that you might want to
try is the ‘ShowRankForEachItem’ method. When set to ‘true’, it
adds the result rank next to each search item. This is especially
useful when the results include several site groupings.
Implementing Your
Changes
Save any changes
to your modified .dwp file. Don’t forget to change the ‘Title’
node to a name that distinguishes it as a custom version (i.e.
‘KMA Custom Search Results’).
Follow the steps above to place
yourself back in design mode.
(1) Delete the current Search Results
web part. You can do this through its context menu
(2) Select the ‘Add Web Parts’ from
the ‘Modify Shared Page’ context menu; select ‘Import’ from its
list
(3) Browse for your modified .dwp
file and import it
(4) Drag your web part onto the page
under the Advanced Search web part
(5) Go to the homepage and execute a
search You can continue to test changes to your web part by
re-executing the steps above.
Summary
You can greatly
enhance the user experience associated with SharePoint search
results by altering and adding a few basic parameters. While these
changes are not a substitute for proper information tagging, they
offer an easy way for more effectively connecting employees with
organizational content.
|