【发布时间】:2014-04-15 08:22:35
【问题描述】:
我正在尝试创建一个基于 Orchard.Search 的自定义搜索模块。我创建了一个名为关键字的自定义字段,已成功将其添加到索引中。我想匹配标题、正文或关键字匹配的内容。使用 .WithField 添加这些或为匹配该术语的每个字段传递字段测试的字符串数组,如果任何字段中存在匹配项,我需要这些来返回内容。我在下面提供了我如何使用这两种方法的示例。
我如何使用搜索生成器的示例:
var searchBuilder = Search()
.WithField("type", "Cell").Mandatory().ExactMatch()
.WithField("body", query)
.WithField("title", query);
.WithField("cell-keywords", query);
String Array FieldNames:
string[] searchFields = new string[2] { "body", "title", "cell-keywords"};
var searchBuilder = Search().WithField("type", "Cell").Mandatory().ExactMatch().Parse(searchFields, query, false);
如果有人能指出我正确的方向,那就太棒了:)
【问题讨论】:
标签: lucene content-management-system orchardcms