SharePoint search error
I am trying to search by scope in SharePoint. i see this error .
My code:
using (SPSite siteCollection = new SPSite("http://sp:25000/"))
{
// create a new FullTextSqlQuery class - use property intializers to set query
FullTextSqlQuery query = new FullTextSqlQuery(siteCollection);
query.QueryText = "SELECT Title" + " from scope() where \"scope\" ='ArticleScope'" + "and Contentclass = 'STS_ListItem_GenericList'";
query.ResultTypes = ResultType.RelevantResults;
query.RowLimit = Int32.MaxValue;
query.TrimDuplicates = true;
query.EnableStemming = false;
query.IgnoreAllNoiseQuery = true;
query.KeywordInclusion = KeywordInclusion.AllKeywords;
query.Timeout = 0x2710;
query.HighlightedSentenceCount = 3;
query.SiteContext = new Uri(siteCollection.Url);
// execute the query and load the results into a datatable
ResultTableCollection queryResults = query.Execute();
ResultTable queryResultsTable = queryResults[ResultType.RelevantResults];
DataTable queryDataTable = new DataTable();
queryDataTable.Load(queryResultsTable, LoadOption.OverwriteChanges);
}
+2
source to share
5 answers
Fixed!!!
Use this link
The code I used:
using (SPSite siteCollection = new SPSite("http://sp:25000/"))
{
Microsoft.Office.Server.Search.Query.FullTextSqlQuery query = new Microsoft.Office.Server.Search.Query.FullTextSqlQuery(siteCollection);
query.QueryText = "SELECT Title from scope() where \"scope\" ='All Sites' and Contentclass = 'STS_ListItem_GenericList'";
query.ResultTypes = Microsoft.Office.Server.Search.Query.ResultType.RelevantResults;
query.RowLimit = Int32.MaxValue;
query.TrimDuplicates = true;
query.EnableStemming = false;
query.IgnoreAllNoiseQuery = true;
query.KeywordInclusion = Microsoft.Office.Server.Search.Query.KeywordInclusion.AllKeywords;
query.Timeout = 0x2710;
query.HighlightedSentenceCount = 3;
query.SiteContext = new Uri(siteCollection.Url);
query.AuthenticationType = Microsoft.Office.Server.Search.Query.QueryAuthenticationType.NtAuthenticatedQuery;
Microsoft.Office.Server.Search.Query.ResultTableCollection queryResults = query.Execute();
Microsoft.Office.Server.Search.Query.ResultTable queryResultsTable = queryResults[Microsoft.Office.Server.Search.Query.ResultType.RelevantResults];
DataTable queryDataTable = new DataTable();
queryDataTable.Load(queryResultsTable, LoadOption.OverwriteChanges);
}
Thanks for your support.
+1
source to share
How do you access SharePoint? In the screenshot, it looks like you have a web page running in a non-SharePoint IIS web application on a SharePoint server that is not supported (linking to a Microsoft.SharePoint assembly from any application running outside of SharePoint is not officially supported. although some functions may work)
What happens if you run this code from SharePoint (i.e., a web part)?
0
source to share