Configuring contextual search to use search center

Posted Thursday, December 9, 2010 10:25 AM by CoreyRoth

I’ve never been a fan of the way contextual search is handled in SharePoint out-of-the-box.  By default, SharePoint has contextual searches go to OSSSearchResults.aspx.   If you aren’t familiar with the term contextual search, you might be familiar with the This Site or the This List search scope options that you see in the search drop down list.

ContextualSearch

The reason I don’t like OSSSearchResults.aspx (besides all of the S in the page name) is that it is an application page and is generally considered not customizable.  This means if you want to configure how results are displayed or the refinement panel, you really can’t directly (without leaving yourself in an unsupported state).  You can make a copy of it and then make customizations, but that is a lot of effort for something so simple. 

I understand why SharePoint uses this page by default though.  The first reason is that SharePoint Foundation does not have a Search Center site template and it needs some place to render search results.  Secondly, even if you have SharePoint Server, you may not have created a search center.  Therefore, it uses this page by default so that search will work without any major configuration.

We want to customize what is on the contextual search page though.  What you can do is reconfigure the Site Collection Search Results Page URL to point to your search center.  We can find this setting in the Search Settings page of your site collection settings.  I talked about these settings in the past.  When you go to this page, you will see that the URL configured is /_layouts/OSSSearchResults.aspx.

SiteCollectionSearchSettings3

We simply change this to the URL of the results.aspx page in your Search Center.  Now, typically I install my search center on a URL such as /Search or /SearchCenter.  Determine what your URL is or go create a search center using the New Site menu.  In my example, we'll use /search.  You will find the results.aspx page in the Pages library, so the full URL we want is /Search/Pages/Results.aspx.  You can also determine this URL by going to your search center and performing a search.  When you enter the URL, leave out the server name.

SiteCollectionSearchSettingsCustomSearchCenter

Once you have finished, we can test our contextual search from any site or document library.

ConextualSearchResults

As you can see, our search results are now in the Search Center and we have things like people search showing up.  However, the results only contain the contextual information from the subsite.  Now, I can customize this page as needed.  The CoreResultsWebPart actually uses two extra query string parameters to make this happen.  The cs parameter has the contextual scope name, This Site.  The u parameter specifies which URL to limit the results to.  As always, the k parameter contains the query itself.   This is a simple customization to implement and I highly recommend it if you want to customize your contextual search results.

Comments

# re: Configuring contextual search to use search center

Friday, December 10, 2010 7:07 AM by Mikael Svenson

Great read!

How would you best go about to provide a link on the search center which takes you back to where your search originated from? And is there a way to display which context your are searching in without doing custom development on the search result page?

# re: Configuring contextual search to use search center

Thursday, February 3, 2011 7:09 AM by svet

Hi, I always see NO result in contextual search... any news ?? thanks

# re: Configuring contextual search to use search center

Friday, February 4, 2011 10:37 AM by CoreyRoth

@svet If contextual search is not working I would go back and verify your alternate access mappings first.  I would also try testing results on your site using the site keyword and a URL.  If it works correctly, you should see results.  If you have a bigger issue, it won't return results.

# re: Configuring contextual search to use search center

Friday, February 4, 2011 10:38 AM by CoreyRoth

@Mikael Sorry for the late reply, I didn't see your comment come through.  Yes, you identified the two common issues with putting your results through the search center.  I think both are going to require a bit of customization to the search center master page (or at the least adding a web part).

# re: Configuring contextual search to use search center

Friday, May 13, 2011 3:03 PM by Chitta

Great article,

I am having a strange issue here. Some time results are showing and sometime not. I have to refresh several time if results are not coming. some time navigators are coming but no result and vice versa. what may be reason?

# re: Configuring contextual search to use search center

Monday, May 16, 2011 2:16 PM by CoreyRoth

@chitta Hard to say.  Are you getting any errors when it occurs?  Does it occur when searching from a particular site or list?

# re: Configuring contextual search to use search center

Wednesday, May 18, 2011 10:01 AM by Nick Chokas

Great article...it helped me a lot.  However, when I go into any of the sub-sites and do a search using "This Site: test", no results show up.  

On the other hand, doing a search using "All Sites" works perfect.

Any ideas?  :-S

# re: Configuring contextual search to use search center

Thursday, May 19, 2011 8:53 AM by CoreyRoth

If the contextual scope (this site) doesn't work I would start by verifying that your alternate access mappings are correct.  If they are not configured, it can prevent contextual search from working.

# re: Configuring contextual search to use search center

Monday, June 13, 2011 3:28 PM by Matt Herring

Corey - Can you provide any details or references to resolving the issue Mikael Svenson brought up?  That's the number one reason I don't use a search center.  The users get lost and the back button has some strange results sometimes.  Thanks.

# re: Configuring contextual search to use search center

Monday, June 20, 2011 4:12 PM by CoreyRoth

@Matt Most people tend to just re-implement the branding they apply to v4.master to a form that actually works with minimal.master.  This gives the user the ability to click elsewhere on the site.

# re: Configuring contextual search to use search center

Wednesday, October 5, 2011 7:22 AM by Vipin

Corey I have my alternate access mapping correct and get the right results for All Sites Search using search center and the same for this site gives no results. I also tried for this list, same results are not popping up. Custom Search scopes are working but Contextual searches are not working and we need both for our project. Please let me know if ou ever faced the same situation. Thanks in advance...

# re: Configuring contextual search to use search center

Monday, October 17, 2011 9:34 PM by CoreyRoth

@vipin The issue for me almost always seems to be related to the AAM. You may want to look at how you have them set up.  Typically, I set the FQDN to the default AAM and then crawl that same URL.  You can add other mappings for the server name, etc.

# re: Configuring contextual search to use search center

Friday, October 28, 2011 6:10 AM by Veerendra

Corey- i have the same problem what Vipin has mentioned. but on the server windows foundation search service is not running.Is because of that the site scope will not resturn results?

# re: Configuring contextual search to use search center

Monday, November 7, 2011 1:13 PM by Jeremy

When I attempt to do this the url is always wrong so I get a 404 error on a search query.

I know the full path to the page is myserver.mycompany.com/.../SearchResults.aspx so I change the site collection search results page to /_catalogs/SearchResults.aspx

This results in the url  myserver.mycompany.com/.../SearchResults.aspx

When I make the search results page /sites/mysitecollection/_catalogs/masterpage/SearchResults.aspx

This results in  myserver.mycompany.com/.../SearchResults.aspx

I just can't win here. What am I missing?

# re: Configuring contextual search to use search center

Monday, November 7, 2011 8:37 PM by CoreyRoth

The search service should not affect it in this case.  Check your alternate access mappings and the URl you are using to crawl on the content source.

# re: Configuring contextual search to use search center

Tuesday, November 29, 2011 12:47 AM by Nikhil

Excellent information,

Configured contextual scope same way as suggested above. But i have a peculiar issue when i redirect my queries to another FAST farm the contextual scope does not display any results.  Both the FARMS have same document counts.

Can you let me know , what could be the issue here ?

# re: Configuring contextual search to use search center

Wednesday, December 7, 2011 8:45 PM by CoreyRoth

@louis Your content source should be configured to use the default alternate access mapping.

# re: Configuring contextual search to use search center

Wednesday, December 7, 2011 8:52 PM by CoreyRoth

@Nikhil not sure what the cause would be there.  

# re: Configuring contextual search to use search center

Wednesday, January 25, 2012 6:12 PM by Ivan

I have set this up at one of my clients.

The only issue that I see is that if the user changes the search term and resubmits, the context disappears. Is there any way around this?

# re: Configuring contextual search to use search center

Wednesday, February 1, 2012 8:13 AM by markus

Hi, this works fine.

But if you configure in the search box of the result site under scopes "show and default to contextual scope" only the scope "this site: xxxx"  works for the next search. The scope "this list: xxxx" will not works for the next crawl instead of this he put "this site: search site" in the scopes dropdown...Any ideas?

# re: Configuring contextual search to use search center

Monday, February 6, 2012 11:52 PM by CoreyRoth

@Markus I don't have a good solution for that.  The reason it doesn't work is because the site has changed and therefore the context has changed as well.

# re: Configuring contextual search to use search center

Friday, February 10, 2012 7:52 PM by bnurick

I would like to see an answer to Ivan's & markus's issue, as I have the same (as everyone will the way this works).  The context is in fact lost on re-search, which really confuses the user.

I started down the path to edit the target search results page, to retain the contextual scope, which eventually messed up All Sites searching, because it defaulted to the Search Site Scope (hah, one issue for another!).

I then reviewed how the default osss context page works, and discovered I was basically re-building that page!!!

So, I am looking for the best practice here, since this behavior can confuse end-users.  

I think the answer here is, you create ANOTHER search page under Search Center, used just for contextual searching.  This way, you set the Search Box to use the contextual scope sent to the page, which will be retained, but you will no break SCOPED searches (All Sites, custom) since they target the other page.

Those are my thoughts.

# re: Configuring contextual search to use search center

Saturday, September 1, 2012 4:04 PM by Rob Garrett

Hi Cory,

Aby idea how to get this working in SP2013? I changed the search settings for my site and site collection to use search center - I even waited the 30 minutes SharePoint tells you to wait (is there a timer service?)... yet, search this site in a team site always uses OSSSearchResults.aspx

Thanks for any help

R.

# re: Configuring contextual search to use search center

Monday, September 10, 2012 8:36 AM by CoreyRoth

@rob I've noticed the same thing in 2013.  I've also been looking at the new global setting that you can set in the search center.  It never changes anything.  I suspect it may be a bug.

# re: Configuring contextual search to use search center

Tuesday, May 28, 2013 9:21 AM by Giorgos Arc

@Rob, @Corey

I had the same issue in 2013. I resolved it by opening a browser at the server as an administrator (Run as...).

That allowed me to uncheck the "use the same results page settings as my parent" and type the Search Center results page.

# re: Configuring contextual search to use search center

Tuesday, July 16, 2013 11:03 AM by CoreyRoth

@Giorgos Arc good tip!

# re: Configuring contextual search to use search center

Tuesday, June 9, 2015 8:22 AM by M Yasir

Roth,

What is the advantage of a search center. why use a search center? what are the features of that are activated in this template.

What if we activate those feature in a normal site. I am actually trying to find what are the benefits of using search center.

and when search center is in place, it does not allow to use "This Site" contextual search and every site/site collection.

Leave a Comment

(required)
(required)
(optional)
(required)