SharePoint Tricks: Adding Google Search To Search Scopes

Tonight’s article is one based on a little trick I pulled of last year at one of my customer’s Intranet. As it turns out, there seems to be quite some people using Google Search (Live Search anyone?) ;-)
So how do we add this search scope? The trick lies in a custom page for the search scope. When creating a search scope in your site collection settings, you’re allowed to enter a custom search page.

 SharePoint Tricks: Google Search Scope Configuration

This custom search page simply has to redirect to the google query webpage: eg.http://www.google.com/search?q=ENTER+A+WORD. Don’t forget to replace the ENTER+A+WORD content of the q variable with the k variable you find in the query string of the custom page. This is whare all the magic lies, you see. So in the end, we’re basicly rerouting the query from SharePoint to Google. Pretty simple, but very effective!

 SharePoint Tricks: Google Searc Scope Use

Hope you guys liked the trick. See you next time!

17 Responses to “SharePoint Tricks: Adding Google Search To Search Scopes”

  1. Links (4/1/2008) « Steve Pietrek’s SharePoint Stuff Says:

    [...] SharePoint Tricks: Adding Google Search To Search Scopes [...]

  2. Bookmarking the web - w15/2008 - double density design Says:

    [...] SharePoint Tricks: Adding Google Search To Search Scopes. [...]

  3. Gaurav Bhati Says:

    Hi,
    I am trying to do exactly what you have mentioned in this blog. But the problem is I can’t somehow replace content of q variable with the k variable. Would you be kind enough to explain this in bit more detail.
    Thanks,
    Gaurav

  4. Tombo Says:

    Guarev,

    In your code you are redirecting to a google url. As you placed the url in your code (probably in a string), you can replace your keyword (in this case “ENTER+A+WORD”, this can be whatever you want, you can even dynamically build the url to redirect to) with the k variale. After that, it’s just redirecting your page to the new url you created!

    Good Luck!

  5. Gaurav Bhati Says:

    Thanks for your reply. I am new to it and still couldn’t understand how to accomplish this. Would you be able to give me step by step reply please ?
    Thanks,
    Gaurav

  6. ScriptKittie Says:

    Wow! That’s really sweet! Hey- real fast I made a .master file and uploaded it to my work’s new intranet. My supervisor can’t see it even though it’s published. She can see different premade ones- just not this one- any advice?

  7. Tombo Says:

    Where did you upload it? You have to upload it to the master page catalog library. You can find this library on following location: http://ROOTOFSITECOLLECTION/_catalogs/masterpage/

    Good luck!

  8. ScriptKittie Says:

    ^_^!! Thank you!!! Yeah- I couldn’t publish it– but my intratnet is looking really spiffy!! <3 I’ll keep checking back!

  9. anonymous Says:

    Well, instead of describing how easy it is, how about some detailed instructions, eg:
    1. Make a copy of ..searchresults.aspx. Call it googleresults.aspx
    2. Open googleresults.aspx in notepad and replace its contents with the following javascript block:…
    3. Create a new search scope and point it to googleresults.aspx

    Telling everyone how easy it is to do, does nothing more than massage your own ego…

  10. Tombo Says:

    For the people still looking for the full code in searchgoogle.aspx. Here it is:

    < %@Page Language="C#"%>
    < % Response.Redirect("http://www.google.com/search/?q="+Request["k"],true); %>

    Anonymous> Why is your message so hostile? From time to time I try to guide you guys to solutions. I’m not a step-by-step handbook. I still do this in my spare time. :-)

  11. anonymous Says:

    Tombo> sorry for the hostility. Your site was the only one that even remotely discussed the process. After a log Googling session, I finally came across your site, then your instructions were difficult to follow and I was very frustrated…

    Thank you for updating the site and providing the code. It worked perfectly, with one minor alteration: There’s no ‘/’ after ’search’ in the Google url. It should be: http://www.google.com/search?q=“+Request

    Thanks again and sorry for the emotive…

  12. dsy Says:

    Hello
    Thanks for this article.

    Where to put the ASPX file: “c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\”

    What to write into the ASPX file:

  13. James Wood Says:

    I couldn’t get this to work on MOSS 2007 under 64 bit Windows 2008 Server R2. All it would do is display the text of the page as if ASPX wasn’t registered on the server, but IIS 7.5 should handle that no problem and the ASP.NET features are installed. Anyone got it working?

  14. Tombo Says:

    No problem over here. :-)

    Tom

  15. David Singh Says:

    Ok I create an aspx page and added your code, I keep getting an error:
    . Code blocks are not allowed in this file. Do you know why that is?

  16. Tombo Says:

    You need to add your aspx file to the SharePoint farm as an application page. Copy it to next directory: c:\program files\common files\microsoft shared\web server extensions\12\template\layouts\
    Now you can access it from: http://server/_layouts/yourpage.aspx

    Cheers
    Tom

  17. David Singh Says:

    Tombo, thanks for the quick response as I am new to this. Followed your suggestions and it worked. Thanks Again!

Leave a Reply