Friday, April 20, 2012

Search Configurations

Farm Level Configuration 

Before perform search in SharePoint 2010 we need to Create and Configure a Search Service Application. After creating a Search Service Application then need to configure crawling. following section shows how to configure Crawl

Crawling Configuration


If we search anything in site collection level, it will never give any results to the user.

After Create and Configure the Search Service Application, we need to do crawling configurations.
·         Login to central admin using the farm admin credential
·         Access to  “Manage service applications” under  “Application Management” 
·         Click on [Search Service Application]
·         Click on  “Content Sources” under “Crawling” in the left navigation


·         Click on the dropdown arrowLocal SharePoint sites” and click “Edit”. (If you want to create a new content source you can create by clicking “New Content Source” button. Here I have used the “Local SharePoint sites”)

 
·         Ensure the following values are set.
·         Give <site> url as the “Start Address” (If there are any <anonymous site> then give that url too).
·         For the schedule of “Full crawl” and “Incremental crawl”, click on “Edit Schedule” and use the default and click OK 
 
·         At the end of this process start full crawl of this content source. Click on the dropdown arrow  “Local SharePoint sites” and click “Start Full Crawl”

Create Crawl Rules


After The Full Crawl is finished, we can search in site collection level. But in search result it gives some odd results as bellow and often need to omit:
§  /SiteCollectionImages/Forms/Thumbnails.aspx
§  /PublishingImages/Forms/Thumbnails.aspx
§  /Pages/Forms/AllItems.aspx
§  /Lists/News/AllItems.aspx
§  /PublishingImages/Forms/AllItems.aspx
§  /Pages/Forms/my-sub.aspx
§  /Pages/Forms/mod-view.aspx
To do this we need to add “Crawl Rules”. Following section shows how to add “Crawl Rules”
·         Access to  “Manage service applications” under  “Application Management”
·         Click on [Search Service Application]
·         In  “Search Service Application” click on “Crawl Rules” under “Crawling”


·         The following table shows some of rules which can be added to exclude content while crawling
Rules
Include or exclude
*://*/pages/default.aspx
Exclude
*://*webfldr.aspx*
Exclude
*://*mod-view.aspx*
Exclude
*://*my-sub.aspx*
Exclude
*://*thumbnails.aspx*
Exclude
*://*allitems.aspx*
Exclude
*://*/lists/*
Exclude

 ·         Click on “New Crawl Rule”


·         Give the path as given in “Rules” column in above table and click “Exclude” option to exclude content while crawling and click OK.
·         Repeat above steps for each rule 

Site Collection Level Configuration

Search settings


The Search box is a small text box with a text as “Search This Site…” which located In the top of the SharePoint site collection. If the user search using this search box then it will go to the SharePoint default search results page. We can create a custom search results page and change to it from default search results page, can give a search center, and can define a set of search scopes which appear next to the search box. These changers can be done from search settings page.
·         Login to root site as site collection administrator
·         Navigate to settings page by Site Actions à Site Settings
·         Click on “Search settings” under “Site Collection Administration”.

There are two options in Search Settings
1.       Enable custom scopes (Such as “All Sites”) by connecting this site collection with the following search center
If you are using a search center then can use this option. You can target your search results to a search center, which is essentially a custom search results page.

2.       Do not use custom scope. Use only contextual scopes (such as “This Site”). Display results in the site collection
By default search will use SharePoint default Search page.
Search drop down modes
·         Do not show scopes dropdown, and default to contextual scope
·         Do not show scopes dropdown, and default to target results page
·         Show scopes dropdown
·         Show, and default to ’s’ URL parameter
·         Show and default to contextual scope
·         Show, do not include contextual scopes
·         Show, do not include contextual scope, and default to ’s’ URL parameter

Search Scopes and Rules


Users can enable Search Scopes to narrow their searches. It will make easier for the user to do a search.
Add a Scope
·       Login as site collection administrator
·      Navigate to settings page by Site Actions à Site Settings
·       Click on “Search scopes” under “Site Collection Administration”.
·       For example I’m adding the “Search All” search scope for the site collection:
·         Search All : To search content in the site and does not search people
·       Click New Scope link and ensure that the following values are set
Title: Search All
Description: Search All - Search the entire web including all

Add rules to the Scope
I have added a rule to “Search All” scope to search in all content as follows
·         Click “New Rule” and set the “Scope Rule Type” as “All Content” and click OK.
I have added another rule to “Search All” scope to exclude people search as follows:
·         Click “New Rule” and set the “Scope Rule Type” as “Property Query”
·         Add the property query as follows:
·         Select “contentclass” from the dropdown
·         urn:content-class:SPSPeople

Display groups


If user needs to change the order of the scopes in scope drop down or to remove any scopes from the scope drop down, then user can do this from display groups in scope settings page.
·         Site Actions à Site Settings
·         Click on “Search scopes” under “Site Collection Administration”.
·         Click On “Display Groups”

     ·   Click on “Search Dropdown” then you can change the order of the scopes in scope drop down or to remove any scopes from the scope drop down.   

Use of Search Center       

The Search Center is a special type of SharePoint site template. By default there is a Basic Search Center sub site called “Search” in site collections. But if there is a case you need to create a Search center and you cannot find the “Basic Search Center” template then you need to add this site template, because this is hidden by default.
You can activate this by following steps:
·         Go to Site Actions->Site Settings
·         Under “Look and Feel” click “Page layouts and site templates”
·         Need to add the “Basic Search Center” sub site template

   
In Search settings user can set the search center and a search results page in search center. To create a search results page follow the following steps:
·         Navigate to search center and click site actions à view all site collections.
·         If user cannot see the pages library then need to activate the “SharePoint publishing feature” in the search center.
·         Go to the pages library and create a new page using “Search Results” page layout. This page can be given to the site collection search results page in “search settings” page. Then the result will be displayed in the new search results page.

Like this user can create pages using advanced search, people search results, and search box page layouts. Each page contains different web parts.
Following are some web parts in Search results page:
·         Search box
·         Search core results
·         Refinement panel
·         Search statistics
·         Search action links

Search Web part Changers 

You can enable the display of scopes drop down to help users limit the content they are searching. Also can create your own custom advanced search or search results pages and configure this web part to navigate to these. User can enable links to advanced search page and preferences page which configure search suggestions and search language.
·         Go to search results page
·         Go to Site Actions à Edit Page
·         Find “Search Box” web part and go to web part properties.


·         Press “OK” at the bottom to apply the changes.
·         Save and close the page 

Enable query suggestions

It is possible to let the search box give you a suggestion when you start typing a search term. For example if user needs query suggestions as bellow image, first need to check the “show query suggestions” check box in “Search Box” web part. After that need to follow bellow configurations in central administration.  
·         Got to Central Administration.
·         Go to Application Management à Manage service applications.
·         Click the Search service application
·         On the Search Administration page, under System Status section, click on “Disable” Query logging. Then it will change to “Enable” status

Did you mean?
To enable the display of the "Did you Mean?" message in the search result page do following steps. 

·         Go to search results page
·         Go to Site Actions à Edit Page
·         Find “Search Summary” web part and go to web part properties.
·         In the Miscellaneous section, check the "Show Messages" checkbox. This checkbox is not checked by default.



Happy Searching!!!

Changing SmallSearchInputBox delegate Control

SmallSearchInputBox is the search control which can be seen on most of SharePoint pages which gives the search option. It gives search scope drop down and will direct user to the search result page or advanced search page.  


The appearance of the search box control (SmallSearchInputBox control) can be change by overriding using a feature as given bellow:
·         In visual studio, add an “Empty Element” to the SharePoint project

 

·         Add following code to the “Elements.xml” file:


<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Control Id="SmallSearchInputBox"
       Sequence="25"
       ControlAssembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral,    PublicKeyToken=71e9bce111e9429c"
       ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx">
    <Property Name="DropDownMode">ShowDD</Property>
    <Property Name="SearchResultPageURL">/Search/Pages/SearchResults.aspx</Property>
    <Property Name="FrameType">None</Property>
    <Property Name="DropDownWidth">140</Property>
    <Property Name="TextBoxWidth">140</Property>
    <Property Name="ShowAdvancedSearch">true</Property>
    <Property Name="TextBeforeDropDown">Search</Property>
    <Property Name="AdvancedSearchPageURL">/Search/Pages/AdvancedSearchResults.aspx</Property>
    <Property Name="QueryPromptString">Search...</Property>
  </Control>
</Elements>


·         Build and deploy the solution.

Monday, April 9, 2012

Migrate a SharePoint 2007 Site to SharePoint 2010

Once I had a user requirement to migrate a SharePoint 2007 site to SharePoint 2010. There are several methods to do this task. I used following method because I need to retain the original values of Modified Date, Created Date, Created By, and Modified By from the SharePoint 2007 site.
Before starting the migration, it’s better to keep a backup of the content database and also need to install SharePoint Service Pack 2.
Get a copy of the Content database of SharePoint 2007 site
·         Go to Microsoft SQL Server Management Studio.

·         Right-click on the content database and select Tasks à Backup…
·         Enter the Backup Name
·         Select the Destination on Disk, and click OK to start the backup of the Content database.
·         Then copy the backup file to the SharePoint 2010 SQL server
Create a new Web application in SharePoint 2010 server
·         Create a new empty Web application on the SharePoint 2010 server,

·         If there are any custom solutions which installed on SharePoint 2007, then install those solutions to the new Web application on the SharePoint 2010 server

Restore the SharePoint 2007 backup file to SharePoint 2010 SQL Server

·         Open Microsoft SQL Server Management Studio on SharePoint 2010 SQL Server.

·         Right-click on Databases and select Restore Database

·         Give a Name to the database (do not use any existing name because this will overwrite)

·         Select the Source for restore as From Device and give the path to the backup file which is copied from SharePoint 2007 server.

·         Click OK to start
Dismount the content database from new SharePoint 2010 web application
·         Open SharePoint 2010 Management Shell

·         To dismount the current SP2010 content database run the following command

      Dismount-SPContentDatabase <ContentdBName>

ContentdBName : content database name of the new SharePoint 2010 web application
Mount the content database to the SharePoint 2010 server
·         Verify that all the needed custom components. If there are any errors, make sure you correct them before mounting the SP2007 content database.
Test-SPContentDatabase -Name < newContentdBName > -WebApplication <URL>
·         If get errors, so add the solutions to the SP 2010 site
Add-SPSolution -LiteralPath <path to the solution>
·         Install Solution
Install-SPSolution -Identity <solution name> -WebApplication < URL > -GACDeployment 

·         If no error, then Mount-SPContentDatabase cmdlet. This cmdlet also upgrades the SP2007 content to SP2010.
Mount-SPContentDatabase <ContentDb> -WebApplication http://<SiteName>

SiteName : The new 2010 site

Visual Upgrade
After upgrading from SharePoint 2007 to 2010 it will give the SharePoint 2007 user interface. To upgrade the to the SharePoint 2010 look and feel:
·         Login as Site Owner and select Site Actions à Visual Upgrade.

·         Select Update the user interface.

·         Click OK. It will upgrade to the SharePoint 2010 look and feel