I have strange issue when I am trying to remove some records from custom solr index.
I created code like this
public void DeleteRecordsFromIndex(string indexName,IEnumerable<IIndexableUniqueId> uniqueIds)
{
if (uniqueIds == null || string.IsNullOrEmpty(indexName) || !uniqueIds.Any())
{
return;
}
using (IProviderDeleteContext deleteContext = ContentSearchManager.GetIndex(indexName).CreateDeleteContext())
{
foreach (var indexId in uniqueIds)
{
deleteContext.Delete(indexId);
}
deleteContext.Commit();
}
}
Search Item property when I need to get UniqueId
[IndexField("_uniqueid")]
public IIndexableUniqueId UniqueId
{
get
{
return new `enter code here`IndexableUniqueId<string>(this.Uri.ToString());
}
}
Based on debug info IIndexableUniqueId contains correct values like:"sitecore://web/{66d75448-72a5-4d94-9788-61c6c64b9251}?lang=en-au&ver=1" what is equal to _uniqueid field in solr index.
I had 4 records in my custom solr index.
After first run one records was removed from index, But 3 records are steel there. I have ran code couple of times, but 3 records always inside of index.
What could be wrong with my code ?