c# - Sitecore 7 搜索所有内容

标签 c# .net sitecore sitecore7

我正在为基于 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 来查询所有内容?

谢谢

最佳答案

Sitecore.ContentSearch.BuiltinFields.Content索引中的字段仅包含媒体库中二进制文件的内容。如果您查看它引用的配置 Sitecore.ContentSearch.ComputedFields.MediaItemContentExtractor .

要搜索所有字段,您需要添加自定义 IComputedIndexField<fields hint="raw:AddComputedIndexField">它聚合了您要搜索的所有字段,或者仅包括您要在 linq 查询中搜索的所有字段。

关于c# - Sitecore 7 搜索所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17188360/

相关文章:

c# - 模拟没有接口(interface)或虚方法的类

c# - 将一个字符串数组复制到另一个

c# - MVC3 - 正在缓存 AJAX 局部 View ......我无法阻止它

c# - 如何避免 .NET CF 3.5 和 CE 6 R3 中的严重错误

asp.net - 名称值列表字段未在自定义项目生成器基类中生成

c# - 在非开发机器上使用逐步调试所需的最低要求

javascript - 如何在JavaScript中使用字节数组将字符串转换为base64编码?

Sitecore 博客评论审核已启用,但评论会在批准之前发布

asp.net-mvc - 在 Sitecore MVC 的 View 中获取媒体 url

.Net 程序被编译为名为 "assemblies."的 DLL 或 EXE 文件类型 程序集是否包含机器可执行代码