mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Deletion of content items from index was using wrong ID
We were using the deletion task ID instead of the content item ID. --HG-- branch : dev
This commit is contained in:
@@ -59,6 +59,7 @@ namespace Orchard.Indexing.Services {
|
|||||||
|
|
||||||
_indexProvider = _indexManager.GetSearchIndexProvider();
|
_indexProvider = _indexManager.GetSearchIndexProvider();
|
||||||
var updateIndexDocuments = new List<IDocumentIndex>();
|
var updateIndexDocuments = new List<IDocumentIndex>();
|
||||||
|
var addedContentItemIds = new List<string>();
|
||||||
DateTime? lastIndexUtc;
|
DateTime? lastIndexUtc;
|
||||||
|
|
||||||
// Do we need to rebuild the full index (first time module is used, or rebuild index requested) ?
|
// Do we need to rebuild the full index (first time module is used, or rebuild index requested) ?
|
||||||
@@ -81,6 +82,7 @@ namespace Orchard.Indexing.Services {
|
|||||||
_contentManager.Index(contentItem, documentIndex);
|
_contentManager.Index(contentItem, documentIndex);
|
||||||
if (documentIndex.IsDirty) {
|
if (documentIndex.IsDirty) {
|
||||||
updateIndexDocuments.Add(documentIndex);
|
updateIndexDocuments.Add(documentIndex);
|
||||||
|
addedContentItemIds.Add(contentItem.Id.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
@@ -116,7 +118,11 @@ namespace Orchard.Indexing.Services {
|
|||||||
|
|
||||||
// process Delete tasks
|
// process Delete tasks
|
||||||
try {
|
try {
|
||||||
_indexProvider.Delete(SearchIndexName, taskRecords.Where(t => t.Action == IndexingTaskRecord.Delete).Select(t => t.Id));
|
var deleteIds = taskRecords.Where(t => t.Action == IndexingTaskRecord.Delete).Select(t => t.ContentItemRecord.Id).ToArray();
|
||||||
|
if (deleteIds.Length > 0) {
|
||||||
|
_indexProvider.Delete(SearchIndexName, deleteIds);
|
||||||
|
Logger.Information("Deleted content items from index: {0}", String.Join(", ", deleteIds));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
Logger.Warning(ex, "An error occured while removing a document from the index");
|
Logger.Warning(ex, "An error occured while removing a document from the index");
|
||||||
@@ -147,6 +153,7 @@ namespace Orchard.Indexing.Services {
|
|||||||
if (updateIndexDocuments.Count > 0) {
|
if (updateIndexDocuments.Count > 0) {
|
||||||
try {
|
try {
|
||||||
_indexProvider.Store(SearchIndexName, updateIndexDocuments);
|
_indexProvider.Store(SearchIndexName, updateIndexDocuments);
|
||||||
|
Logger.Information("Added content items to index: {0}", String.Join(", ", addedContentItemIds));
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
Logger.Warning(ex, "An error occured while adding a document to the index");
|
Logger.Warning(ex, "An error occured while adding a document to the index");
|
||||||
|
Reference in New Issue
Block a user