kamagra how much to take

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:

  1. RunQuery("SELECT FileExtension, ContentClass, IsDocument, title, path, author from scope() ");
  2.  
  3. public static RunQuery(string queryText)
  4. {
  5. FullTextSqlQuery query = new FullTextSqlQuery(SPContext.Current.Site);
  6. query.ResultTypes = ResultType.RelevantResults;
  7. query.QueryText = queryText;
  8. ResultTableCollection resultCollection = query.Execute();
  9. DataTable resultDataTable = new DataTable();
  10. ResultTable resultTable = resultCollection[ResultType.RelevantResults];
  11. resultDataTable.Load(resultTable);
  12. }

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.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>