Thursday, February 23, 2012

SharePoint 2010 Search Method failed with unexpected error code 3


I run into very interesting problem when trying to modify the topology of my search service application. I was basically trying to move my administration component and index role to another server in the same farm, but the wizard kept crashing with TimerJob timeout error.

They say the definition of madness is trying the same thing over and over again and expect different result....what can I say, I tried at least 10 times. Draw your own conclusions here. 

When looking at my target server (where I was trying to place my admin and index role), the search service would be in status Error Staring and the application server log would show

Search Method failed with unexpected error code 3.

I then I decided to give a try to our old friend stsadm:

stsadm.exe -o osearch -action start but to no avail. Same error message. Off course, no amount of reboots and timer service restarts helped either.

Finally, I found this blog that talked about the underlying file structure and the share that's being configured. Sure enough, my folder structure under D:\Index_Files was missing, even though the share still existed.

The fix was simple, but then they all are once you nail down the problem:

  1. Copy folders from working index server under D:\Index_files, or wherever you are pointing your index files on your particular search service application (namely Config and Office Server folders)
  1. On command line, run psconfig -cmd secureresources (this will apply security on these folders automatically)
  1. On command line, run stsadm -o osearch -action start (your search service should now be able to start)
  1. Finally apply your topology changes

Moral of the story: when all else fails, look at the simple stuff first :)





Fab 40 templates in SP 2010 activation


If you downloaded the redesigned Fab 40 templates (there are actually substantially less than 40 templates for SharePoint 2010 as of yet) from here , you may run into difficulties when trying to create your sites. Apparently, there are multiple features that need to be installed on the site collection ahead of time, and the site creation wizard will keep complaining.

For example, you may see error message regarding feature 6c09612b-e1ef-4867-8396-531430c60f2 not being activated, and as soon you do that and retry, yet another missing feature error pops up.
Rather than trying to chase them down one by one , quick and dirty to bypass these errors is:

Step 1: install all features by issuing
Install-spfeature -allexistingfeatures

Step 2: Activate all features with the scope of "site" to the site collection where you want to create your sites based on Fab 40 templates. This will issue whole bunch of error messages since many of the site features are already activated, nevertheless it will take care of the ones that are missing.

get-spfeature | ForEach-Object{if($_.scope -eq "site" ){Enable-SPFeature $_.id -Url your_site_collection_url}}





Export and Import Content Types


Recently we needed to migrate custom content types from one web application to another.

I tried the most straight-forward approach first: use the new content type hub feature of the Managed Metadata Service App. The idea was to mark the site collection containing these content types as content type hub, and essentially subscribe the rest of the site collections to consume from it.
Due to the way they were originally created, we kept getting errors trying to use this.

 After digging around for a while, the solution was to break down the process in two steps: work with site columns first, and then work with content types based on these columns:

  1. Export custom site columns from the original site collection: results will go into  site columns xml file. For this I used sitecolumn utility from Codeplex.
  2. Export custom content data types from the original site collection: this will create xml file with definitions for content types from  the content type group you filter on
  1. Import custom site columns from the exported site columns xml file : again Codeplex
  1. Re-create custom content types in the target site


$sourceWeb = Get-SPWeb http://portal
$xmlFilePath = "C:\Install\Script-SiteContentTypes.xml"
#Create Export File
New-Item $xmlFilePath -type file -force
#Export Content Types to XML file
Add-Content $xmlFilePath ""
Add-Content $xmlFilePath "`n"
$sourceWeb.ContentTypes | ForEach-Object {
    if ($_.Group -eq "Custom Content Types") {
        Add-Content $xmlFilePath $_.SchemaXml
    }
}
Add-Content $xmlFilePath ""
$sourceWeb.Dispose()

$destWeb = Get-SPWeb http://portal/sites/migrationtest
$xmlFilePath = "C:\Install\Script-SiteContentTypes.xml"



#Create Site Content Types
$ctsXML = [xml](Get-Content($xmlFilePath))
$ctsXML.ContentTypes.ContentType | ForEach-Object {
    #Create Content Type object inheriting from parent
    $spContentType = New-Object Microsoft.SharePoint.SPContentType ($_.ID,$destWeb.ContentTypes,$_.Name)
   
    #Set Content Type description and group
    $spContentType.Description = $_.Description
    $spContentType.Group = $_.Group
   
    $_.Fields.Field  | ForEach-Object {
        if(!$spContentType.FieldLinks[$_.DisplayName])
        {
            #Create a field link for the Content Type by getting an existing column
            $spFieldLink = New-Object Microsoft.SharePoint.SPFieldLink ($destWeb.Fields[$_.DisplayName])
       
            #Check to see if column should be Optional, Required or Hidden
            if ($_.Required -eq "TRUE") {$spFieldLink.Required = $true}
            if ($_.Hidden -eq "TRUE") {$spFieldLink.Hidden = $true}
       
            #Add column to Content Type
            $spContentType.FieldLinks.Add($spFieldLink)
        }
    }
   
    #Create Content Type on the site and update Content Type object
    $ct = $destWeb.ContentTypes.Add($spContentType)
    $spContentType.Update()
    write-host "Content type" $ct.Name "has been created"
}
$destWeb.Dispose()

This script has been taken from Phil Childs' blog which can be found  here , so big thanks to him.

FAST for SharePoint- No Search Results Returned


FAST for SharePoint-no results returned

I recently encountered peculiar problem when configuring FAST for SharePoint server in my lab environment. I was using the MS technet document


After configuring the two Search Service Apps (Content and Query) and starting full crawl, I was able to see items in the default search content collection "sp" by running

Get-FASTSearchContentCollection -name "sp"


The problem was, even though the items were supposedly in the index, I was unable to get any results while searching. This was true for both searching via SharePoint FAST search center site, and when trying to use the built-in QRServer on FAST (which can be accessed locally on the FAST server by browsing to http://localhost:13280 if you keep all defaults during configuration, or at http://localhost:base port+280 if you changed the base port)


To make things even more interesting, I was able to feed a document manually using:
Docpush -c sp


and this document was showing up on both QRServer and SharePoint FAST search center with no problems.


The problem turns out, is I had added the fast service account to the local administrators group on the FAST server, IN ADDITION to it being in the FastSearchAdministrators local group that's created by default after FAST configuration.
This I assume caused search results to be security-trimmed in very unexpected ways.

The fix was easy enough: remove the fast service account from local admins group on FAST server, reset the index on SharePoint, on the Content SSA, followed by cleaning up the sp content collection on FAST.

After re-indexing on the content SSA, documents started showing up in search results.