OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.42k stars 2.39k forks source link

ContentItem is randomly Indexed in only one Lucene Index #12044

Closed mariojsnunes closed 5 months ago

mariojsnunes commented 2 years ago

Describe the bug

I have two Lucene Indexes:

  1. Content (only published)
  2. ContentManagement (latest)

On rare occasions, after updating an existing Article, it is only indexed on ContentManagement and disappears from the Content Index.

To Reproduce

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.

Skrypt commented 2 years ago

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?

mariojsnunes commented 2 years ago

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. image image

Yeah and it is re-indexed most of the time, the issue happens rarely...

sebastienros commented 2 years ago

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.

jtkech commented 2 years ago

@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));
}
Piedone commented 5 months ago

Closing due to no reply from the author.