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


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


I cannot see the error as it is blocked by my proxy. However, I am assuming there and

must be a space before . (Is there any reason why this isn't one long line?)

'ArticleScope' "+" and
                   ^

If you can't copy and paste the error in your question.

0


source


You are missing a space before and.

It means

where \"scope\" ='ArticleScope'" + "and Contentclass = 'STS_ListItem_GenericList'

      

becomes

where \"scope\" ='ArticleScope'and Contentclass = 'STS_ListItem_GenericList'

      

'ArticleScope' and AND combined: 'ArticleScope' and

0


source


Are you using Microsoft SharePoint Server 2007 (MOSS)? Or do you only have Windows SharePoint Services 3.0 (WSS)? From what I've seen, Scopes is a MOSS feature not available in WSS, but I'm guessing a bit.

0


source







All Articles