Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing Latest not working as intended #12691

Merged
merged 3 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,11 @@ private Document CreateLuceneDocument(DocumentIndex documentIndex, LuceneIndexSe
var doc = new Document
{
// Always store the content item id and version id
new StoredField("ContentItemId", documentIndex.ContentItemId.ToString()),
new StoredField("ContentItemVersionId", documentIndex.ContentItemVersionId.ToString())
// These fields need to be indexed as a StringField because it needs to be searchable for the writer.DeleteDocuments method.
// Else it won't be able to prune oldest draft from the indexes.
// Maybe eventually find a way to remove a document from a StoredDocument.
new StringField("ContentItemId", documentIndex.ContentItemId.ToString(), Field.Store.YES),
new StringField("ContentItemVersionId", documentIndex.ContentItemVersionId.ToString(), Field.Store.YES)
};

if (indexSettings.StoreSourceData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ await shellScope.UsingAsync(async scope =>
var allPublishedContentItems = await contentManager.GetAsync(updatedContentItemIds);
allPublished = allPublishedContentItems.DistinctBy(x => x.ContentItemId).ToDictionary(k => k.ContentItemId, v => v);
var allLatestContentItems = await contentManager.GetAsync(updatedContentItemIds, latest: true);
allLatest = allLatestContentItems.DistinctBy(x => x.ContentItemId).ToDictionary(k => k.ContentItemVersionId, v => v);
allLatest = allLatestContentItems.DistinctBy(x => x.ContentItemId).ToDictionary(k => k.ContentItemId, v => v);

// Group all DocumentIndex by index to batch update them
var updatedDocumentsByIndex = new Dictionary<string, List<DocumentIndex>>();
Expand Down