Site icon @WonderLaura

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:

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


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!

Exit mobile version