feat: generate sitemap.xml from ES index with correct last_updated dates#2900
Open
feat: generate sitemap.xml from ES index with correct last_updated dates#2900
Conversation
Add a new CLI command that queries the Elasticsearch lexical index for real last_updated dates and generates sitemap.xml with correct per-URL lastmod values, replacing the DateTime.UtcNow placeholder. The build command still produces a sitemap with DateTime.UtcNow for backwards compatibility. The new `assembler sitemap` command overwrites it with correct dates when run after ES indexing in the CI workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Label error. Requires exactly 1 of: automation, breaking, bug, changelog:skip, chore, ci, dependencies, documentation, enhancement, feature, fix, redesign. Found: |
Comment on lines
+47
to
+65
| foreach (var hit in hits) | ||
| { | ||
| if (hit is not IDictionary<string, object> dict | ||
| || dict["_source"] is not IDictionary<string, object> source) | ||
| continue; | ||
|
|
||
| var url = source["url"]?.ToString(); | ||
| var lastUpdatedStr = source["last_updated"]?.ToString(); | ||
|
|
||
| if (url is null || lastUpdatedStr is null) | ||
| continue; | ||
|
|
||
| // Use sort array from the hit for search_after cursor | ||
| if (dict.TryGetValue("sort", out var sortObj) && sortObj is object[] sortValues) | ||
| lastSortValues = sortValues; | ||
|
|
||
| var lastUpdated = DateTimeOffset.Parse(lastUpdatedStr, CultureInfo.InvariantCulture); | ||
| yield return new SitemapEntry(url, lastUpdated); | ||
| } |
Comment on lines
+104
to
+107
| catch (Exception ex) | ||
| { | ||
| logger.LogWarning(ex, "Failed to close PIT (non-fatal)"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
assembler sitemapCLI command that queries the ES lexical index for reallast_updateddates and generatessitemap.xmlwith correct per-URLlastmodvaluessearch_afterwith PIT for efficient pagination over >10k documentsDateTime.UtcNowfor backwards compatibility;assembler sitemapoverwrites it after ES indexingCI workflow change required
After merging, update
.shared.assemble-build-and-deploy.ymlindocs-internal-workflowsto add after theassembler indexstep:Test plan
SitemapBuilder.Generate(correct XML, ordering, directory creation)EsSitemapReader.BuildSearchBody(pagination, hidden filter, escaping)assembler sitemapagainst a dev ES cluster🤖 Generated with Claude Code