我正在为一个基于Sitecore的网站设计一个搜索网站。我已经能够做到这一点了。
var query = SearchContext.GetQueryable<MySearchResultItem>().Where(i =>
i.ItemContent.Contains(this._View.SearchTerm)).ToArray();MySearchResultsItem的定义如下。
public class MySearchResultItem
{
// Will match the _name field in the index
[IndexField("_name")]
public string Name
{
get;
set;
}
[IndexField(Sitecore.ContentSearch.BuiltinFields.Content)]
public string ItemContent
{
get;
set;
}
}当我使用搜索时
[IndexField("_name")],我得到了正确的结果。但我想搜索项目的所有字段,我认为这是可能的
[IndexField(Sitecore.ContentSearch.BuiltinFields.Content)]。
我做错了什么?我应该使用哪个IndexField来查询所有内容?
谢谢
发布于 2013-06-21 04:28:25
索引中的Sitecore.ContentSearch.BuiltinFields.Content字段仅包含媒体库中二进制文件的内容。如果你看一下配置,它引用了Sitecore.ContentSearch.ComputedFields.MediaItemContentExtractor。
要搜索所有字段,您需要向<fields hint="raw:AddComputedIndexField">添加一个自定义IComputedIndexField,它聚合了要搜索的所有字段,或者只包含要在linq查询中搜索的所有字段。
https://stackoverflow.com/questions/17188360
复制相似问题