C# SharePoint 2010关键字查询返回空的托管属性
我按照上的说明创建了一些托管属性。然后,我使用关键字查询搜索创建了一个自定义SharePoint应用程序页面,以使用以下代码仅查找文档:C# SharePoint 2010关键字查询返回空的托管属性,c#,sharepoint,sharepoint-2010,applicationpage,keywordquery,C#,Sharepoint,Sharepoint 2010,Applicationpage,Keywordquery,我按照上的说明创建了一些托管属性。然后,我使用关键字查询搜索创建了一个自定义SharePoint应用程序页面,以使用以下代码仅查找文档: using System; using System.Collections.Generic; using System.Data; using Microsoft.Office.Server.Search.Query; using Microsoft.SharePoint.WebControls; protected System.Data.DataTab
using System;
using System.Collections.Generic;
using System.Data;
using Microsoft.Office.Server.Search.Query;
using Microsoft.SharePoint.WebControls;
protected System.Data.DataTable TrySearch(string keywords, Int32 pageSize, Int32 page, out Int32 totalPages)
{
int startRow = (page - 1)*rowLimit;
var kwq = new KeywordQuery(Site);
kwq.QueryText = string.Format("Title:\"{0}\"", keywords);
kwq.ResultTypes = ResultType.RelevantResults;
kwq.RowLimit = pageSize;
kwq.StartRow = startRow;
kwq.TrimDuplicates = true;
kwq.HiddenConstraints = "path:\"*/User Docs*\" AND IsDocument:true";
kwq.KeywordInclusion = KeywordInclusion.AllKeywords;
// Default
kwq.SelectProperties.Add("WorkId");
kwq.SelectProperties.Add("Rank");
kwq.SelectProperties.Add("Title");
kwq.SelectProperties.Add("Path");
kwq.SelectProperties.Add("SiteName");
kwq.SelectProperties.Add("HitHighlightedSummary");
kwq.SelectProperties.Add("HitHighlightedProperties");
kwq.SelectProperties.Add("ContentClass");
kwq.SelectProperties.Add("IsDocument");
// Custom (they come back blank even when set as managed properties)
kwq.SelectProperties.Add("IntroText");
kwq.SelectProperties.Add("Date");
kwq.SelectProperties.Add("ListItemId");
ResultTableCollection rtc = kwq.Execute();
var results = new DataTable();
if (rtc.Count == 0)
{
totalPages = 0;
return results;
}
using (ResultTable relevantResults = rtc[ResultType.RelevantResults])
{
results.Load(relevantResults, LoadOption.OverwriteChanges);
totalPages = (int) Math.Round((double) relevantResults.TotalRows/pageSize);
}
return results;
}
我的问题是,无论我做什么,我都无法恢复托管属性的值。搜索工作正常。我可以进行相应的筛选并得到预期的结果,只是自定义列是空的。我最关心的是ID,但我想得到我要求的所有定制属性
服务器上是否有我错过的设置?非常感谢您的帮助。我想您现在一定已经找到了解决方案,但对于那些为同一问题苦苦挣扎的人来说,解决方案是:
将已爬网的属性映射到现有/新的托管属性后,再次爬网。就这样。将显示请求属性的数据。老实说,我从未找到解决方案。我已经有一段时间没做那个项目了,但我相信我会再次尝试爬行。如果项目回到我的方式,我会重新考虑这个。谢谢