在 SharePoint 2010 的 FAST 搜索中使用 KeywordQuery 以编程方式为 HitHighlightedSummary 生成 HTML
我正在尝试开发一个用于快速搜索的自定义 SharePoint 2010 Web 部件。我正在使用 Microsoft.Office.Server.Search.Query.KeywordQuery
,如下所示:
var FASTquery = new KeywordQuery(proxy)
{
ResultsProvider = SearchProvider.FASTSearch,
QueryText = queryText,
ResultTypes = ResultType.RelevantResults | ResultType.RefinementResults
};
FASTquery.SelectProperties.AddRange(
new string[] { "Title", /* ..., */ "HitHighlightedSummary" });
ResultTableCollection searchResults = FASTquery.Execute();
我继续将 searchResults[ResultType.RelevantResults]
绑定到 Repeater< /代码> 控制。我试图通过调用
FASTquery.HighlightStringValue()
。我传递的值是来自 searchResults
的 HitHighlightedSummary
。搜索“ear”时的结果示例如下:
<ddd/>FALSE ); GetDlgItem(IDC_<c0>EAR</c0>_PAIN_STATIC)->EnableWindow<ddd/>FALSE ); GetDlgIte(IDC_<c0>EAR</c0>_PAIN_ABSENT_RADIO<ddd/>FALSE ); GetDlgItem(IDC_<c0>EAR</c0>_PAIN_MILD_RADIO<ddd/>
但是,当使用这样的字符串调用时,FASTquery.HighlightStringValue()
会抛出 System.ServiceModel。错误异常
,消息为“值不在预期范围内”。
将此摘录转换为 HTML 的正确方法是什么,或者我应该使用其他值调用 HighlightStringValue()
吗?该文档并不是特别有帮助。
I am trying to develop a customized SharePoint 2010 web part for FAST search. I am using Microsoft.Office.Server.Search.Query.KeywordQuery
something like this:
var FASTquery = new KeywordQuery(proxy)
{
ResultsProvider = SearchProvider.FASTSearch,
QueryText = queryText,
ResultTypes = ResultType.RelevantResults | ResultType.RefinementResults
};
FASTquery.SelectProperties.AddRange(
new string[] { "Title", /* ..., */ "HitHighlightedSummary" });
ResultTableCollection searchResults = FASTquery.Execute();
I go on to bind searchResults[ResultType.RelevantResults]
to a Repeater
control. I'm trying to get the "hit highlighted summary" to appear by calling FASTquery.HighlightStringValue()
. The value I'm passing is the HitHighlightedSummary
from searchResults
. An example of what this looks like for a result when searching for "ear" is:
<ddd/>FALSE ); GetDlgItem(IDC_<c0>EAR</c0>_PAIN_STATIC)->EnableWindow<ddd/>FALSE ); GetDlgIte(IDC_<c0>EAR</c0>_PAIN_ABSENT_RADIO<ddd/>FALSE ); GetDlgItem(IDC_<c0>EAR</c0>_PAIN_MILD_RADIO<ddd/>
However, when called with a string like this, FASTquery.HighlightStringValue()
is throwing a System.ServiceModel.FaultException
with the message "Value does not fall within the expected range."
What is the correct way to convert this excerpt to HTML, or should I be calling HighlightStringValue()
with some other value? The documentation is not particularly helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通常将点击突出显示的摘要标记手动转换为 HTML。您将在摘要中找到两个标记的组合:
标记的手动转换可以像以下字符串替换一样简单:
I typically perform a manual conversion of the hit highlighted summary markup to HTML. You'll find a combination of two markers in the summary:
A manual transformation of the markup could be as simple as the following string replacement: