SharePoint搜索错误

时间:2009-09-15 06:48:19

标签: sharepoint sharepoint-2007

我正在尝试在SharePoint中搜索范围。我明白了 error

我的代码:

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);
}

5 个答案:

答案 0 :(得分:1)

固定!!!

已使用this链接

我使用的代码:

 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);
        }

感谢您的支持。

答案 1 :(得分:0)

您是如何访问SharePoint的?从屏幕截图看,似乎您在SharePoint服务器上的非SharePoint IIS Web应用程序中运行了一个Web页面,这是不受支持的(从正在SharePoint外部运行的任何应用程序引用Microsoft.SharePoint程序集是正式不受支持的,即使某些功能可能会运行)

如果从SharePoint中(即在Web部件中)运行此代码会发生什么?

答案 2 :(得分:0)

我无法看到错误,因为它被我的代理阻止了。不过我的猜测是你应该在and之前有一个空格。 (有什么理由说这不是一个长串吗?)

'ArticleScope'" + "and
                   ^

如果没有,请将错误复制并粘贴到您的问题中。

答案 3 :(得分:0)

你在和之前错过了一个空格。

这意味着

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

成为

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

'ArticleScope'和AND连接:'ArticleScope'和

答案 4 :(得分:0)

您使用的是Microsoft SharePoint Server 2007(MOSS)吗?或者您只有Windows SharePoint Services 3.0(WSS)?从我看到的,Scopes是WSS中没有的MOSS功能,但我猜测了一下。