【问题标题】:Delete record from custom sitecore 7 Index从自定义 sitecore 7 索引中删除记录
【发布时间】:2014-07-31 11:39:15
【问题描述】:

我在 Sitecore 中创建了一个自定义索引,我想删除一条记录。我必须提到,这个索引不索引站点核心项目。

我正在尝试这样的事情:

 public void Delete(IIndexableUniqueId uniqueId)
 {
   ContentSearchManager.GetIndex(Constants.MyIndexName).Delete(uniqueId);
 }

索引没有任何反应。

【问题讨论】:

    标签: c# lucene sitecore sitecore7


    【解决方案1】:

    如果您有自定义索引(不是站点核心项目),您应该索引代表唯一 ID 的字段。

    [IndexField("_uniqueid")]
        public override IIndexableUniqueId UniqueId
        {
          get
          {
            return new IndexableUniqueId<string>("uniqueidvalue");
          }
        }
    

    我将使用该“唯一值”以这种方式从索引中删除:

    public void Delete(IIndexableUniqueId uniqueidvalue)
    {
      using (IProviderDeleteContext deleteContext = ContentSearchManager.GetIndex(Constants.MyIndexName).CreateDeleteContext())
      {
        deleteContext.Delete(uniqueidvalue);
        deleteContext.Commit();
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多