If you're querying multiple Site Collections use FullTextSQLQuery
since it searches across the farm and if you plan to query Pages Library of a single Site Collection, use SPSiteDataQuery
instead. I think you might need SPSiteDataQuery
?
SPSiteDataQuery queryObj = new SPSiteDataQuery();
//query Pages libraries
queryObj.Lists = "<Lists ServerTemplate='850' />";
queryObj.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='FileRef' />";
queryObj.Webs = "<Webs Scope='Recursive' />";
DataTable dt = SPContext.Current.Web.GetSiteData(query);
foreach (DataRow row in dt.Rows)
{
//do something else
}
P.S. FullTextSqlQuery
may not always return the freshest of data but you can reduce the incremental crawl schedule to 15 mins or 30 mins.
Update:
Set the QueryText property of your FullTextSQLQuery
object like this:
fullTextSqlQuery.QueryText =
"select title, ContentClass from scope() where (contentclass = 'STS_List_850')";
"STS_List_850": // denotes a Page Library