ContentItem is randomly Indexed in only one Lucene Index
Describe the bug
I have two Lucene Indexes:
- Content (only published)
- ContentManagement (latest)
On rare occasions, after updating an existing Article, it is only indexed on ContentManagement and disappears from the Content Index.
To Reproduce
- I cannot reproduce this issue, it has been reported multiple times in production.
- I've restored the DB point-in-time before and after the issue occured and could not reproduce locally.
- I've confirmed on the DB the item has the flags Latest = 1 and Published = 1 when it disappears.
- If I reindex the Content Index it will appear again.
- I'm using an Azure Linux App Service.
- There are no errors in the logs.
- We are using IContentManager to publish the items... UpdateAsync followed by PublishAsync.
Expected behavior
The item is indexed in both Indexes
I understand this is a tricky one, I'm posting in case this happened to someone else, or if someone has any idea what's happening.
If you are using the ContentManager to update your content item it should re-index properly. Are you updating the content item with the OrchardCore.Content API or is it done from a server-side ContentHandler?
If you are using the ContentManager to update your content item it should re-index properly. Are you updating the content item with the OrchardCore.Content API or is it done from a server-side ContentHandler?
It's server-side code, where we use IContentManager.

Yeah and it is re-indexed most of the time, the issue happens rarely...
Can you check if there is enough logging in the code where the indexing is done, and if so enable it? It might help identity the issue since there is no consistent repro.
@mariojsnunes
At least you may need to also use ValidateAsync().
await contentManager.UpdateAsync(contentItem);
var result = await contentManager.ValidateAsync(contentItem);
if (result.Succeeded)
{
await contentManager.PublishAsync(contentItem);
}
Hmm, here some code I'm using
var result = await contentManager.UpdateValidateAndCreateAsync(contentItem, VersionOptions.Published);
if (!result.Succeeded)
{
throw new ValidationException(string.Join(", ", result.Errors));
}