SharePoint Contextual Searching and Stemming

I’d like to share with you a fix that I’ve found for the fact that search term stemming is not available when doing contextual searches in SharePoint.  Jennifer Mason and I worked through this the other day, and the results are pretty interesting.

Here’s my explanation of contextual searching:

In SharePoint, when performing a search, you’ll notice that there’s a drop-down box to pick from All Sites, or if you’re on a sub-site, there will be an option for “This Site”.  If you’re currently at the list or library level, there will be an option for “This List”.  Searching using This Site or This List is called a contextual search.  You’re only searching within that location.

As a SharePoint administrator, you may have noticed this:  When you perform a search throughout “All Sites”, and are then taken to a results page, that search results page is customizable.  You can add and remove web parts from the page, and customize the settings inside those search results web parts.  One such search results customization that can be done, is to turn on “Stemming”.  Basically, this means that when you search for a word, such as Trade, the search results will return other tenses and such, like Trading, Traded, Trades, etc.

With the search results being so configurable when you search “All Sites”… unfortunately, the search results page is not configurable at all when contextual searches are done, because the search results page exists on a page in the _layouts directory, called osssearchresults.aspx.  By default, search term stemming is NOT turned on here.

So, how do we allow search stemming on our contextual search results pages?  THIS POST has the answer, which I am now expounding upon.

1.  On each SharePoint server, navigate to the following file on the server:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\osssearchresults.aspx

2. Copy it to create a backup of this original file

3. Open the file in Notepad

4. Do a text search for the following term:
SearchWC:CoreResultsWebPart

5. Go to the THIRD instance of this term.  It’s almost at the very end of the file. (this is very important, because I tried this solution with the FIRST instance of the term, and it doesn’t work that way)

6. Add the following: StemmingEnabled=true
So that the whole line looks like:
<SearchWC:CoreResultsWebPart runat=”server” ShowActionLinks=false ChromeType=”None” StemmingEnabled=true/>

7. Save

8. Do an IISRESET

That’s it.  From that point on, search results will all have stemming turned on in the results, whether it’s a contextual search or not.  Doing another crawl will not make a difference as to how the results are displayed on this page.

Again, thanks Jennifer, for showing me what the heck contextual search is, and helping me work through this fix!

9 comments

  • Does it not rely on some kind of thesaurus file or contro for stemming?

    Like

  • susannelson@ccimail.com

    Thanks! I’ve been looking for a solution for this for some time now and had unsuccessfully tried editing the first instance of the term.

    Like

  • Oscar.Berke@yahoo.com

    Will this same method work for WSS 3.0? I ask because there obviously is no all sites search OOTB with WSS 3.0, so not sure if this line would be there in the file or not…

    Like

  • Thank you very much. It worked for me and I spent hours searching for this solution.

    Like

  • Joyce_slavik@gbtpa.com

    Worked great!!! For WSS 3.0, I changed this line in searchresults.aspx in 12 hive from: to:

    Like

  • Ranjeet Bhargava

    Hi Laura, Its great post. Is there any way that we can do text mining like how we can search the text / content written in any doc file of any document library with Share Point 2010? I mean to say If typing a word which is in a word file then that file should come in search result.

    Like

  • Ranjeet, Sharepoint search already does what you’re asking about. It does that automatically.

    Like

  • Dear Laura,

    Is there any way to implement search on hyperlinks column in Link lists..?
    If possible plz help with solution..

    Like

  • Rohit,
    You’d need to go to your search administration and it will need to be a crawled property. In 2013, this is under Search Schema.

    Like

Leave a reply or question

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s