SharePoint Saturday – Search

Today is Melbourne’s turn to host SharePoint Saturday – with a bunch of presentations, demos and a panel session – all discussing SharePoint – and the entire event is FREE – for the people, by the people.

Lots of great topics about SharePoint 2010 – all the new features, developer need-to-know’s, Office 2010 client, and 3rd-party product demo’s such as Nintex, and K2.

I’m doing a double-up session with Tim Wragg (StarGate) – about Enterprise Search within MOSS (2007).

He’ll be showing some of the customisation and configuration that you can achieve with OOTB components for SharePoint – and I’ll then discuss the extensibility story with search – using the SharePoint SDK & API.

Here’s a few of the topics I’ll be covering :

  • Create a custom coded webpart with C# – new UI for Search
  • Call to the SQLFullTextQuery class to retrieve search results
  • Demo of a utility to assist – called SharePoint Search Service Tool (CodePlex)
  • Discussion of CustomProtocolHandler to extend even further
  • Search Admin using code – for creating scopes, properties, etc

Hope to see you at the session – I’ll load up the PPTX (slide deck) after all is said and done – and you can have a look at your leisure.

🙂

UPDATE :  Here’s a link to the slide deck from today’s session (~1.8MB zip).   .

…and here is the prank BSOD I used – thought I’d get a few more “gasps” or “laughs”…

I guess if there were MORE people there – might have helped…

FullTextSqlQuery throwing exception – this site is not assigned to an indexer

Following on from my presentation at SharePoint Saturday in Melbourne, I thought I’d relay a tip to those looking to code a webpart or such using FullTextSqlQuery.

During the development of my code, I was getting errors when running the following code :

FullTextSqlQuery fullTextSqlQuery = new FullTextSqlQuery(SPContext.Current.Site)
{
    ResultTypes = ResultType.RelevantResults, 
    QueryText = stringBuilder.ToString(),
    TrimDuplicates = true,
    EnableStemming = true,
    StartRow = 1,
    RowLimit = 200,
    TotalRowsExactMinimum = 300,
    IgnoreAllNoiseQuery = false,
};

//Return the search results to a ResultTableCollection
resultTableCollection = fullTextSqlQuery.Execute();

What was happening in the UI was a message stating :

Your search cannot be completed because this site is not assigned to an indexer. Contact your administrator for more information.

Took me a few DAYS of investigation to work a fix – as the code was compiling, and executing – just couldn’t connect to the Search Service within SharePoint.

And it turns out that my code was somehow causing a COM Exception within the WSS Search Service – and was listed in the Event Viewer also. 

I was having to go to Control Panel > Services – and re-start the “Windows SharePoint Search” service.

What’s going on !

Well – you may be aware that there’s a separate web service for both WSS and MOSS.  It follows that you can use the API to interact with either of these – and my code was incorrectly trying to use the WSS not MOSS class libraries.

The core issue was with my project references within Visual Studio

The key to my discovery was with this code :

ResultTypes = ResultType.RelevantResults, 

When I tried to add the option for “SpecialTermResults” (aka BestBets), I was getting a .NET error – saying ‘invalid member’ or something :

ResultTypes = ResultType.RelevantResults, ResultType.SpecialTermResults,  

But – this is within the SharePoint class library from MSDN.

It was then that I realised my FullTextSqlQuery class was referenced from :

  • using Microsoft.SharePoint.Search.Query   // WSS

– instead of

  • using Microsoft.Office.Server.Search.Query   // MOSS

It follows that the project file (DLL) references were wrong also. 

And yep – swapping them out fixed the problem !    *phew*

So – if you’re having this error – then check your solution/project references :

WSS Search

DLL : C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12ISAPIMicrosoft.SharePoint.Search.dll

NameSpace : Microsoft.SharePoint.Search.Query

MOSS Search

DLL : C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12ISAPIMicrosoft.Office.Server.Search.dll

NameSpace : Microsoft.Office.Server.Search.Query

Kinda obvious in the end :

  • If included as “SharePoint” only – it’s WSS
  • Need to have “Office Server” for MOSS

Wish I’d known all this earlier – it would have saved me a few stressful days !

🙂