Solving SharePoint FullTextSqlQuery Wrong Site Collection Error
The FullTextSqlQuery class is really nice for building readable query statements, all in familiar SQL syntax. While it's a lot easier to use when querying data, the returned content is limited to that which has been indexed by SharePoint.
This is something to keep in mind, the indexing part. Consider the following code snippet, delivered as a generic static method:
-
RunQuery("SELECT FileExtension, ContentClass, IsDocument, title, path, author from scope() ");
-
-
public static RunQuery(string queryText)
-
{
-
query.ResultTypes = ResultType.RelevantResults;
-
query.QueryText = queryText;
-
ResultTableCollection resultCollection = query.Execute();
-
ResultTable resultTable = resultCollection[ResultType.RelevantResults];
-
resultDataTable.Load(resultTable);
-
}
While running such code, you may encounter a problem where the wrong site collections are returning data. It may crop up in the form of a particular site collection being always used, or a weird permutation of site collections. If this problem occurs, there are generally two causes of the problem.
1) Ensure you are referencing Microsoft.Office.Server.Search.Query.FullTextSqlQuery and not Microsoft.SharePoint.Search.Query.FullTextSqlQuery
2) Ensure in Central Administration / Site Settings / Search And Offline Availability /Indexing Site Content the content is being indexed.
Related posts:
- Enumerating All SPWebs In SPFarm.Local Into Strongly Typed Collection
- IT Consulting Ethics – Part 3 – Benefit-Cost Analysis and Government Considerations
- Using the KeywordQuery Class to Get a List of Department Employees
- Using the KeywordQuery Class to Get a List of Departments
- SharePoint 2010 Folder Design Best Practices
3 Comments »
RSS feed for comments on this post. TrackBack URL























Articles & Research
SharePoint Architecture
Research Methodology
Personal/Off-Topic
Article Or Research Filed Under 

[...] Solving SharePoint FullTextSqlQuery Wrong Site Collection Error [...]
Pingback by Links (4/12/2010 « Steve Pietrek-Everything SharePoint/Silverlight) — April 12, 2010 @ 7:05 pm
I’ve recently started a blog, the information you provide on this site has helped me tremendously. Thank you for all of your time & work.
Comment by Paul Leal — May 2, 2010 @ 10:26 pm
I am not sure where you are referring to when you said,
Central Administration / Site Settings / Search And Offline Availability /Indexing Site Content
That’s all.
Comment by Clark — September 24, 2010 @ 12:31 pm