1
我想索引不是Sitecore項目的Sitecore用戶。如何在Sitecore 7中創建一個自定義索引來索引非Sitecore項目(例如用戶)
如果我想創建組合不同Sitecore項目的不同字段的自定義索引,那麼同樣的方法我該怎麼做。假設我有某種數據提供程序/存儲庫返回的數據,我如何創建,配置,索引這些數據。
我已經寫了一些配置這個索引:
<configuration type="Sitecore.ContentSearch.LuceneProvider.LuceneSearchConfiguration, Sitecore.ContentSearch.LuceneProvider">
<indexes hint="list:AddIndex">
<index id="custom_user_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
<param desc="name">$(id)</param>
<param desc="folder">$(id)</param>
<!-- This initializes index property store. Id has to be set to the index id -->
<!--<param desc="propertyStore" ref="contentSearch/databasePropertyStore" param1="$(id)" />-->
<commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
<policies hint="list:AddCommitPolicy">
<policy type="Sitecore.ContentSearch.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
</policies>
</commitPolicyExecutor>
<locations hint="list:AddCrawler">
<crawler type="PT.Forum.Framework.Users.Infrastructure.UserCrawler, PT.Forum.Framework.Users"/>
</locations>
</index>
</indexes>
</configuration>
我履帶做到這一點:
public class UserCrawler : AbstractProviderCrawler
{
public override void Initialize(ISearchIndex index)
{
Assert.ArgumentNotNull(index, "index");
Database = "web";
Assert.IsNotNull(Database, "Database element not set.");
Assert.IsNotNull(Root, "Root element not set.");
base.Initialize(index);
LuceneIndex index2 = index as LuceneIndex;
if (Operations == null)
{
Operations = new LuceneIndexOperations(index2);
CrawlingLog.Log.Info(string.Format("[Index={0}] Initializing LuceneDatabaseCrawler. DB:{1}/Root:{2}", index.Name, Database, Root));
}
var users = new UserRepository().GetByConstraint(UserRepositoryContraints.IsNejTakPlusUser);
index.Configuration = new LuceneIndexConfiguration();
var updateContext = index.CreateUpdateContext();
Operations.Add(new ForumUser(users.First()), updateContext, index.Configuration);
}
}
但該指數配置爲空。
我寫了一篇關於Sitecore 7索引機制的博客文章。也許這會幫助你:http://www.partechit.nl/en/blog/2013/04/sitecore-7-in-depth- indexing-mechanics –
我的問題與您的博客帖子中的「3.3.1特殊字段」部分有關。 Aparently所有computedIndexFields爲空,因爲我得到所有字段記錄的AddComputedIndexFields()方法中的錯誤。 –