Thursday, July 2, 2009

Changing SharePoint default search scope

If you have Advanced Search enabled in your SharePoint site, then on your site’s home page Search drop down box, you will see 3 options :
This Site : Your Site Name (This will search only on the current site collection)
All Sites (This will search in everywhere in farm)
People (This is for searching people from AD)

In the drop down the default selected scope is “All Sites”. That means whenever user wants to search something on your site, he has to change value in drop down every time. So it is very obvious to change the default to “This Site : Your Site Name”, because most of the times user wants to search only in your site.

To change this default value, we need to make only one change in following file:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\OSearchEnhancedFeature\ SearchArea.xml

We have to add one PropertyName line at the end of the file (right after line <property name="ShowAdvancedSearch">true</property>)

<property name="DropDownMode">ShowDD_DefaultContextual</property>

That’s it. We are done.
The only thing that most of us wouldn’t like is to modify oob xml file. But I think we can add/remove this line using feature in this file. So that we can overcome all known issues.

3 comments:

  1. Nice and very useful information.

    I have one question for you, It seems that by changing Searcharea.xml file, it affects all the SharePoint site into farm, but if I would like to change default scope for only one web application, then Is it possible to change and how we can do that?

    thank you very much in advance,
    Sanket Shah

    ReplyDelete
  2. Sanket, thanks for your comment. I believe ther is a way for doing it in that way too. I guess we have to add some JavaScript in the Site Definition Master page which on pageload change the default scope to first value in dropdown. I have mot tried for it, but I will for sure.

    ReplyDelete
  3. This is waht I am talking about:
    http://social.technet.microsoft.com/Forums/en-US/sharepointadmin/thread/85305e7d-3157-46ed-a1e5-048d64dcd611

    ReplyDelete