fix(opensearch): honor sort=score in OS non-scroll read path (#36494) - #36643
Conversation
ContentFactoryIndexOperationsOS.addSorting entered its `score` branch and added only the secondary sort (default `moddate desc`), never the primary `_score` sort. Relevance-sorted queries (`sort=score`) therefore returned default moddate ordering — silently wrong results — once reads switch to OpenSearch (Phase 2+). The scroll path (OSContentletScrollImpl) already does this correctly; this aligns the non-scroll path with it and with the ES read path: primary `_score` desc, then the secondary sort. Adds OpenSearchUpgradeSuite coverage asserting relevance ordering (not moddate) and secondary-sort override behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @fabrizzio-dotCMS's task in 58s —— View job Code Review: fix(opensearch): honor sort=score in OS non-scroll read path
SummaryThe fix is correct and minimal. The The two added tests are well-designed regression guards:
New IssuesNo issues found. Notes (non-blocking, pre-existing — not introduced by this PR)
The PR does exactly what it claims, aligns the two OS read paths, and adds meaningful coverage. LGTM. | Branch: |
…core # Conflicts: # dotCMS/src/main/java/com/dotcms/content/index/opensearch/ContentFactoryIndexOperationsOS.java
|
Tick the box to add this pull request to the merge queue (same as
|
Proposed Changes
Fixes #36494.
During the ES→OpenSearch migration, content queries sorting by relevance (
sort=score) silently lost their ordering once reads switched to OpenSearch (Phase 2+): they came back in defaultmoddate descorder instead of_scoreorder. HTTP 200, plausible-looking hit set, wrong order — the kind of regression count-based parity checks can't catch. Root cause:ContentFactoryIndexOperationsOS.addSorting'ssortBy.startsWith("score")branch added only the secondary sort and never the primary_scoresort.What this PR still changes
Production —
ContentFactoryIndexOperationsOS.addSorting: addunmappedType(Date)to the secondary field sort in thescorebranch, matching the scroll path (OSContentletScrollImpl). Without it,sort=score <field>fails on indices where the secondary field is not mapped, instead of degrading gracefully. Behavior for all other sort inputs is unchanged.Tests
Added to
OpenSearchUpgradeSuite(ContentFactoryIndexOperationsOSIntegrationTest) — new coverage not present onmain:test_searchHits_sortByScore_shouldOrderByRelevanceNotModdate— indexes docs so relevance order is the exact reverse of moddate order; asserts scores come back descending and the most-relevant doc is first (guards against the original regression).test_searchHits_sortByScore_secondaryOverride_shouldApplySecondarySort— equal-score docs,sort=score moddate asc; asserts the secondary sort breaks the tie.Acceptance Criteria
addSortingadds the primary_score(desc) sort in thescorebranch, secondary sort after it (now onmainvia bug(index): product fixes & findings from phased (ES→OS) integration runs #36501/fix(os-search): honor track_total_hits and _score sort on the OpenSearch read path (#36501) #36557; preserved through the merge).unmappedType(Date)sosort=score <field>does not fail on indices missing that field.sort=scorereturns relevance ordering in Phase 2/3 (suite coverage).sort=score <field> <dir>secondary-sort override behaves correctly (suite coverage).OSContentletScrollImpl) unchanged (already correct).🤖 Generated with Claude Code
This PR fixes: #36494