為搜尋建立入站篩選器

將專案新增到搜尋索引時應用入站過濾器,並允許指定專案是否包含在索引中。

可以使用入站篩選器的示例 - 不包括索引中專案的標準值和先前版本。

入站過濾器在配置中設定:

<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