我正在为外部搜索引擎构建索引,并且在解析/呈现所见即所得中内联小部件的内容时遇到问题。
DocumentQuery articleDetailNodes = tree.SelectNodes("ArticleViewModel");
foreach (TreeNode general in articleDetailNodes)
{
Console.WriteLine("Adding [Article]: " + general.GetValue("DocumentName").ToString());
generalIndex.Add(new GeneralIndexItem
{
objectID = general.NodeGUID.ToString(),
title = general.GetValue("DocumentName")?.ToString(),
description = CMS.MacroEngine.MacroResolver.Resolve(general.GetValue("Body").ToString()),
excerpt = general.Parent.GetValue("Excerpt")?.ToString() + " " + general.Parent.GetValue("CardTitle")?.ToString() + " " + general.Parent.GetValue("CardSubtitle")?.ToString() + " " + general.Parent.GetValue("CardDescription")?.ToString(),
page_url = domain + general.NodeAliasPath
});
}
我期望描述的值呈现为 HTML,但我得到的是:
{^widget|(widget_displayname)Color+Family+Filter+-+Large|(name)ColorFamilyFilter_Large|(width)|(height)^}<br />\r\n
如果您想对小部件建立索引,您应该考虑使用智能搜索爬虫而不是制作自定义索引。如果您需要自定义它,您可以查看此链接或使用以下代码:
if (e.IsCrawler)
{
TreeNode page = e.Node;
e.SearchDocument.Add("path_field_name", page.NodeAliasPath, true, true);
}