从solr索引中删除sitecore项,而无需发布父项

问题描述

我遇到了业务需求,我想从master&web中删除项目,也要从solr索引中删除相应的项目。业务不想发布父项,因为同级或父级可能会发生更改,因此我无法触发任何策略,例如 onPublishEndAsync onPublishEndAsyncSingleInstance onPublishEndAsyncPreview 在这里,我正在尝试以下操作,但它不起作用

    var ParentItem = item.Parent;
                using (new EditContext(item))
                {
                    if (Sitecore.Configuration.Settings.RecycleBinActive)
                        item.Recycle();
                    else
                        item.Delete();
                }
                   if (item == null)
                return;
            ISearchIndex index = ContentSearchManager.GetIndex((SitecoreIndexableItem)ParentItem );
            if (index == null)
                return;
            index.Refresh(new SitecoreIndexableItem(ParentItem )); or 
           index.RefreshAsync(new SitecoreIndexableItem(item),IndexingOptions.ForcedIndexing,new System.Threading.CancellationToken());

我在sitecore日志或solr日志文件中没有收到任何错误,但索引没有删除项目

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)