Skip to content

Index HTML documents under canonical URLs and populate additional_urls - #495

Open
Jan-Kazlouski-elastic wants to merge 4 commits into
mainfrom
fix/canonical-url-and-additional-urls
Open

Index HTML documents under canonical URLs and populate additional_urls#495
Jan-Kazlouski-elastic wants to merge 4 commits into
mainfrom
fix/canonical-url-and-additional-urls

Conversation

@Jan-Kazlouski-elastic

@Jan-Kazlouski-elastic Jan-Kazlouski-elastic commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Part of https://github.com/elastic/sdh-search/issues/1986

Part of #261

When a crawled HTML page declares a canonical URL that differs from the fetched URL, index the document under the canonical URL and record the fetched URL in additional_urls. This matches the behavior described in docs/features/CRAWLER_DIRECTIVES.md and prevents duplicate documents for URL variants such as tracking query parameters.

Changes:

  • DocumentMapper uses the canonical URL for url and document id when a valid canonical tag points elsewhere
  • additional_urls records alternate URLs discovered during the crawl, including multiple variants of the same canonical page
  • Coordinator no longer enqueues a separate crawl for the canonical URL, since the page content is already available from the variant

Related context: search-team#3139 discusses canonical tags and duplicate-content handling in Enterprise Crawler. That issue is closed and out of scope here — Open Crawler does not implement duplicate-content detection, and this PR does not add content fingerprinting for pages whose canonical URL differs in body or links.

Checklists

Pre-Review Checklist

  • This PR does NOT contain credentials of any kind, such as API keys or username/passwords (double check crawler.yml.example and elasticsearch.yml.example)
  • This PR has a meaningful title
  • This PR links to all relevant GitHub issues that it fixes or partially addresses
    • If there is no GitHub issue, please create it. Each PR should have a link to an issue
  • this PR has a thorough description
  • Covered the changes with automated tests
  • Tested the changes locally
  • Added a label for each target release version (example: v0.1.0)
  • Considered corresponding documentation changes
  • Contributed any configuration settings changes to the configuration reference
  • Ran make notice if any dependencies have been added

Changes Requiring Extra Attention

  • Security-related changes (encryption, TLS, SSRF, etc)
  • New external service dependencies added.

Related Pull Requests

Release Note

HTML pages with a canonical URL link tag are now indexed under the canonical URL. Alternate crawled URLs for the same page are stored in additional_urls, reducing duplicate documents for URL variants.

When a crawled page declares a different canonical URL, store the canonical
in url/id and record the fetched URL in additional_urls instead of enqueueing
a separate crawl for the canonical page.
Keep alternate URLs discovered for the same canonical page in memory so
later writes include every variant, including when the canonical URL itself
is crawled directly.
Use a self-referential canonical URL in the matching-url example and
expect additional_urls in sorted order when accumulating variants.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant