Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

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

share|improve this answer
    
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
    
This was correct in my case, thanks –  Eric Herlitz Feb 4 '13 at 13:14
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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