简体   繁体   English

Sitecore Lucene索引更新策略:syncMaster

[英]Sitecore Lucene Index Update Strategy: syncMaster

I am using syncMaster lucence index strategy (because I want real time data) 我正在使用syncMaster Lucence索引策略(因为我需要实时数据)

<strategies hint="list:AddStrategy">
    <strategy ref="contentSearch/indexUpdateStrategies/syncMaster" />
</strategies>

I am using Luke - Lucene Index Toolbox to view the index documents.The question I want to ask is, When I rebuild the index my_country_index . 我正在使用Luke-Lucene Index Toolbox查看索引文档。我想问的问题是,当我重建索引my_country_index And I know there are 6 country items in sitecore for which I rebuild the index. 而且我知道Sitecore中有6个国家/地区项目需要为其重建索引。 So with Luke I see 6 documents. 因此,对于Luke我看到了6个文档。

For one of above item with ID ' {DEA26CDA-9EA9-4F67-BB3F-13CAF6A68061} ' with every update for this Item I see an additional document is added (I see with Like). 对于ID为' {DEA26CDA-9EA9-4F67-BB3F-13CAF6A68061} '的上述项目之一,此项目的每次更新都添加了一个附加文档(与Like一样)。 So in the index I have this item with old and new data. 所以在索引中,我有包含新旧数据的此项。 Is it the correct behavior for the syncMaster strategy. 这是syncMaster策略的正确行为。

Yes this is normal behaviour in Sitecore if your index are related master database. 是的,如果您的索引与主数据库相关,这是Sitecore中的正常行为。 On web database you have just one version for every language of an item. 在Web数据库上,每种商品的每种语言只有一个版本。

You can implement a custom crawler that overrides custom behaviour: 您可以实现一个覆盖自定义行为的自定义搜寻器:

public class CustomIndexCrawler : DatabaseCrawler
{
   protected override void IndexVersion(Item item, Item latestVersion, Sitecore.Search.IndexUpdateContext context)
   {
    if (item.Versions.Count > 0 && item.Version.Number != latestVersion.Version.Number)
        return;

    base.IndexVersion(item, latestVersion, context);
    }
}

This will force on indexing to have just last version of an item. 这将强制索引仅具有项目的最新版本。 You need to assign this custom crawler to your class 您需要将此自定义搜寻器分配给您的班级

Other option is when you query results to get just the latest version. 其他选项是当您查询结果以获取最新版本时。 You need to check if _latestversion equals to 1. 您需要检查_latestversion是否等于1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM