简体   繁体   English

将Search API与Sharepoint Foundation 2010一起使用-0个结果

[英]Using the Search API with Sharepoint Foundation 2010 - 0 results

I am a sharepoint newbee and am having trouble getting any search results to return using the search API in Sharepoint 2010 Foundation. 我是一个Sharepoint新手,并且在使用SharePoint 2010 Foundation中的搜索API获取任何搜索结果以返回时遇到了麻烦。

Here are the steps I have taken so far. 这是我到目前为止已采取的步骤。

  1. The Service Sharepoint Foundation Search v4 is running and logged in as Local Service Service Sharepoint Foundation Search v4正在运行并以本地服务身份登录
  2. Under Team Site - Site Settings - Search and Offline Availability, Indexing Site Content is enabled. 在“团队网站-网站设置-搜索和脱机可用性”下,启用了“索引网站内容”。
  3. Running the PowerShell script Get-SPSearchServiceInstance returns 运行PowerShell脚本Get-SPSearchServiceInstance返回

TypeName : SharePoint Foundation Search TypeName:SharePoint基础搜索
Description : Search index file on the search server 描述:搜索服务器上的搜索索引文件
Id : 91e01ce1-016e-44e0-a938-035d37613b70 ID:91e01ce1-016e-44e0-a938-035d37613b70
Server : SPServer Name=V-SP2010 服务器:SPServer名称= V-SP2010
Service : SPSearchService Name=SPSearch4 服务:SPSearchService名称= SPSearch4
IndexLocation : C:\\Program Files\\Common Files\\Microsoft Shared\\Web Server Exten sions\\14\\Data\\Applications IndexLocation:C:\\ Program Files \\ Common Files \\ Microsoft共享\\ Web服务器扩展\\ 14 \\ Data \\ Applications
ProxyType : Default ProxyType:默认
Status : Online 状态:在线

  1. When I do a search using the search textbox on the team site I get a results as I would expect. 当我使用团队网站上的搜索文本框进行搜索时,会得到预期的结果。

Now, when I try to duplicate the search results using the Search API I either receive an error or 0 results. 现在,当我尝试使用Search API复制搜索结果时,我收到一个错误或0个结果。

Here is some sample code: 这是一些示例代码:

using Microsoft.SharePoint.Search.Query;
using (var site = new SPSite(_sharepointUrl, token))
{
    // 
    FullTextSqlQuery fullTextSqlQuery = new FullTextSqlQuery(site)
    {
        QueryText = String.Format("SELECT Title, SiteName, Path FROM Scope() WHERE \"scope\"='All Sites' AND CONTAINS('\"{0}\"')", searchPhrase),
        //QueryText = String.Format("SELECT Title, SiteName, Path FROM Scope()", searchPhrase),
        TrimDuplicates = true,
        StartRow = 0,
        RowLimit = 200,
        ResultTypes = ResultType.RelevantResults
        //IgnoreAllNoiseQuery = false
    };

    ResultTableCollection resultTableCollection = fullTextSqlQuery.Execute();
    ResultTable result = resultTableCollection[ResultType.RelevantResults];

    DataTable tbl = new DataTable();
    tbl.Load(result, LoadOption.OverwriteChanges);
}

When the scope is set to All Sites I retrieve an error about the search scope not being available. 当范围设置为“所有站点”时,我检索到有关搜索范围不可用的错误。 Other search just return 0 results. 其他搜索仅返回0个结果。

Any ideas about what I am doing wrong? 关于我在做什么错的任何想法吗?

This is the workaround we came up with. 这是我们想出的解决方法。

  1. We did not get the foundation search to work as we had hoped. 我们没有像我们希望的那样进行基础搜索。 We will review it again once the RTM version of Sharepoint Foundation is released. Sharepoint Foundation的RTM版本发布后,我们将再次进行审查。

  2. We installed Search Server Express 2010 beta. 我们安装了Search Server Express 2010 Beta。 This allowed us to use the office server namespaces and the corresponding classes. 这使我们可以使用Office服务器名称空间和相应的类。 This worked as expected and we were able to programmatically search against Sharepoint Foundation. 这按预期工作,我们能够以编程方式针对Sharepoint Foundation进行搜索。

I also never got results by using FullTextSqlQuery on Foundation Search but perhaps you can use KeywordQuery: 我也从未在Foundation Search上使用FullTextSqlQuery获得结果,但是也许可以使用KeywordQuery:

        SPSite thisSite = SPControl.GetContextSite(Context);
        Microsoft.SharePoint.Search.Query.KeywordQuery kwQuery = new Microsoft.SharePoint.Search.Query.KeywordQuery(thisSite);
        kwQuery.RowLimit = 1000;
        kwQuery.QueryText = "searchString";         
        kwQuery.HiddenConstraints = "site:\"http://devXX:800/test/docs\"";
        kwQuery.ResultTypes = ResultType.RelevantResults;
        ResultTableCollection results = kwQuery.Execute();
        ResultTable relevantResults = results[ResultType.RelevantResults];            
        dt.Load(relevantResults, LoadOption.OverwriteChanges);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM