我按照http://technet.microsoft.com/en-us/library/ff621097(v=office.14).aspx的说明创建了一些托管属性。然后,我创建了一个带有SharePoint搜索的自定义KeywordQuery应用程序页面,仅使用以下代码查找文档:
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,但我很想得到我所要求的所有自定义属性。
服务器上可能有我错过的设置吗?任何帮助都是非常感谢的。
发布于 2014-02-04 07:08:19
我想你现在一定已经找到了解决办法,但对于那些为同样问题而挣扎的人来说,解决办法是:
在将爬行属性映射到现有/新的托管属性之后,再次爬行。就这样。数据将显示为请求的属性。
https://stackoverflow.com/questions/15510154
复制相似问题