【问题标题】:SharePoint 2010 KeywordQuery Returns Empty Managed PropertiesSharePoint 2010 关键字查询返回空托管属性
【发布时间】:2013-03-08 18:09:53
【问题描述】:

我按照http://technet.microsoft.com/en-us/library/ff621097(v=office.14).aspx 的说明创建了一些托管属性。然后,我使用以下代码创建了一个自定义 SharePoint 应用程序页面,其中包含关键字查询搜索以仅查找文档:

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,但我很想获得我要求的所有自定义属性。

会不会是我在服务器上遗漏了某种设置?任何帮助表示赞赏。

【问题讨论】:

    标签: c# sharepoint sharepoint-2010 applicationpage keywordquery


    【解决方案1】:

    我想你现在一定已经找到了解决方案,但是对于那些在同样的问题上苦苦挣扎的人来说,解决方案是:

    将抓取的属性映射到现有/新的托管属性后,再次抓取。而已。将显示所请求属性的数据。

    【讨论】:

    • 老实说,我从来没有找到解决方案。我已经有一段时间没有从事那个项目了,但我相信我会再次尝试爬行。如果该项目以我的方式恢复,我将重新审视这一点。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-14
    相关资源
    最近更新 更多