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 !
🙂
you saved my days and nights man!
LikeLike
Many, many thanks. You saved me lots o’ time.
LikeLike
Really saved my butt with this, many thanks!
LikeLike
You saved my life! Thx
LikeLike
Thanks:) This really helped
LikeLike