2

I'm developing a web part (in VS 2010 for SharePoint 2010) to seach all content in a Publishing Site Collection. I have the following code (just testing before I change the scope and the select fields) :

FullTextSqlQuery q = new FullTextSqlQuery(SPContext.Current.Site);

q.QueryText = "SELECT ContentType FROM SCOPE() WHERE \"scope\"='All Sites'";

q.ResultTypes = ResultTypes.RelevantResults;

ResultTableCollection qr = q.Execute();

When (in debug) it gets to the last line I get the following error :

"ScopeNotFoundException was handled by user code"

"Scope in your query does not exist"

I have also tried this on a team site and get the same error. If I remove the scope condition ("SELECT ContentType FROM SCOPE()") I get results returned. Obviously the 'All Sites' scope is shared (I tried this after a custom scope didn't work). The search on the publishing site works as normal.

I have also made sure that my scopes are shared (tried with some custom scopes to no avail).

Any help would be greatly appreciated.

1

While not a direct answer, this codeplex tool may help with building the correct syntax for the query.

1

Two assemblies with same class: Microsoft.SharePoint.Search.Query.FullTextSqlQuery Use this one instead: Microsoft.Office.Server.Search.Query.FullTextSqlQuery

  • While this may answer the question it doesn't explain why. Please consider revising your question to include more detail. – Hugh Wood Nov 21 '12 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.