为搜索创建入站筛选器

将项目添加到搜索索引时应用入站过滤器,并允许指定项目是否包含在索引中。

可以使用入站筛选器的示例 - 不包括索引中项目的标准值和先前版本。

入站过滤器在配置中设置:

<indexing.filterIndex.inbound>
 <processor type="Sitecore.ContentSearch.Pipelines.IndexingFilters.ApplyInboundIndexFilter, Sitecore.ContentSearch"></processor>
</indexing.filterIndex.inbound>  

代码实现:

public class ApplyInboundIndexVersionFilter : InboundIndexFilterProcessor   
{        
    public override void Process(InboundIndexFilterArgs args)       
    { 
        var item = args.IndexableToIndex as SitecoreIndexableItem;

        if (!item.Item.Versions.IsLatestVersion())            
        {                  
            args.IsExcluded = true;            
        }
    }
}

更多示例和信息可以在 http://www.sitecore.net/learn/blogs/technical-blogs/sitecore-7-development-team/posts/2013/04/sitecore-7-inbound-and-outbound- 找到。过滤 pipelines.aspx