2011-09-30 39 views

回答

3

您使用的是Advanced Database Crawler謝謝?如果是這樣,那麼您可以添加一些部分,以便通過其GUID包含特定字段,並通過GUID排除特定字段。下面,說明由<include>節點的暗示屬性定義的字段是否應包含或排除

<master type="Sitecore.SharedSource.Search.Crawlers.AdvancedDatabaseCrawler,Sitecore.SharedSource.Search"> 
    <Database>master</Database> 
    <Root>/sitecore/content</Root> 
    <IndexAllFields>false</IndexAllFields> 

    <include hint="list:IncludeField"> 
    <!-- some field you'd want to include --> 
    <fieldId>{8CDC337E-A112-42FB-BBB4-4143751E123F}</fieldId> 
    </include> 

    <include hint="list:ExcludeField"> 
    <!-- __revision field --> 
    <fieldId>{8CDC337E-A112-42FB-BBB4-4143751E123F}</fieldId> 
    <!-- __context menu field --> 
    <fieldId>{D3AE7222-425D-4B77-95D8-EE33AC2B6730}</fieldId> 
    <!-- __security field --> 
    <fieldId>{DEC8D2D5-E3CF-48B6-A653-8E69E2716641}</fieldId> 
    <!-- __renderings field --> 
    <fieldId>{F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E}</fieldId> 
    </include> 

你可以看到a sample search config for the Advanced Database Crawler在SVN我提供了一個片段。

+0

感謝馬克,但沒有我沒有使用高級數據庫爬行。我正在使用常規的Sitecore.Search.Crawlers.DatabaseCrawler。有沒有辦法做到這一點 ? –

2

如果您使用的是標準Sitecore DatabaseCrawler,我建議您創建一個從Sitecore數據庫爬網程序繼承的自定義爬網程序,然後重寫AddAllFieldsMethod。然後,只需配置您的索引使用自定義履帶

你可以看一下對高級數據庫抓取了如何可以做一個示例的源代碼。像這樣的東西:(注意這還沒有測試)

public class DatabaseCrawler : Sitecore.Search.Crawlers.DatabaseCrawler 
{ 
    protected override void AddAllFields(Lucene.Net.Documents.Document document, Sitecore.Data.Items.Item item, bool versionSpecific) 
    { 
     if(IndexAllFields) 
     { 
      base.AddAllFields(document, item, versionSpecific); 
     } 
     else 
     { 
      var fieldsToIndex = new List<string>() {"title", "Text"}; 
      foreach (var field in fieldsToIndex) 
      { 
       var scField = item.Fields[field]; 
       document.Add(new LuceneField(scField.Key, scField.Value, LuceneField.Store.NO, LuceneField.Index.UN_TOKENIZED)); 
      } 
     } 
    } 
}