Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从自定义sitecore 7索引中删除记录_C#_Lucene_Sitecore_Sitecore7 - Fatal编程技术网

C# 从自定义sitecore 7索引中删除记录

C# 从自定义sitecore 7索引中删除记录,c#,lucene,sitecore,sitecore7,C#,Lucene,Sitecore,Sitecore7,我在Sitecore中创建了一个自定义索引,我想删除一条记录。我必须提到的是,该索引不索引sitecore项目 我正在尝试这样的事情: public void Delete(IIndexableUniqueId uniqueId) { ContentSearchManager.GetIndex(Constants.MyIndexName).Delete(uniqueId); } 索引不会发生任何变化。如果您有自定义索引(不是sitecore项目),则应为表示唯一id的字段编制索引

我在Sitecore中创建了一个自定义索引,我想删除一条记录。我必须提到的是,该索引不索引sitecore项目

我正在尝试这样的事情:

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

索引不会发生任何变化。

如果您有自定义索引(不是sitecore项目),则应为表示唯一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();
  }
}