Skip to content

fix(search): add tiebreaker sort to prevent export truncation on numeric sort fields#27429

Closed
harsh-vador wants to merge 2 commits intomainfrom
fix-search-export-explore-page
Closed

fix(search): add tiebreaker sort to prevent export truncation on numeric sort fields#27429
harsh-vador wants to merge 2 commits intomainfrom
fix-search-export-explore-page

Conversation

@harsh-vador
Copy link
Copy Markdown
Contributor

Describe your changes:

Problem

Search export truncated at ~1000 rows when sorting by numeric fields (e.g. totalVotes).

Root cause:

search_after pagination with no tiebreaker. When many documents share the same totalVotes value (e.g. 0), the cursor search_after=[0] asks for docs where totalVotes < 0 → empty batch → loop breaks early.

Fix

Add name.keyword ASC as a tiebreaker sort whenever:

  • Primary sort is _score (was already present, now uses constants)
  • isExport=true — new flag passed to buildSearchRequestBuilder to distinguish export calls from regular search
    This guarantees a unique cursor per document regardless of the primary sort field, enabling stable search_after pagination across all 50K+ rows.

Changes

  • ElasticSearchSearchManager.java — added SORT_FIELD_SCORE / SORT_TYPE_KEYWORD constants; isExport param on buildSearchRequestBuilder; merged tiebreaker condition; replaced magic strings in buildHierarchyQuery
  • OpenSearchSearchManager.java — identical changes

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented Apr 16, 2026

Code Review ✅ Approved

Adds a tiebreaker sort to the search implementation to ensure consistent ordering and prevent export truncation on numeric fields. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (21 flaky)

✅ 3639 passed · ❌ 0 failed · 🟡 21 flaky · ⏭️ 89 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 477 0 3 4
🟡 Shard 2 645 0 2 7
🟡 Shard 3 647 0 6 1
🟡 Shard 4 621 0 3 27
✅ Shard 5 616 0 0 42
🟡 Shard 6 633 0 7 8
🟡 21 flaky test(s) (passed on retry)
  • Features/DataAssetRulesDisabled.spec.ts › Verify the Chart entity item action after rules disabled (shard 1, 2 retries)
  • Flow/Tour.spec.ts › Tour should work from welcome screen (shard 1, 1 retry)
  • Pages/UserCreationWithPersona.spec.ts › Create user with persona and verify on profile (shard 1, 1 retry)
  • Features/BulkEditEntity.spec.ts › Glossary (shard 2, 1 retry)
  • Features/ChangeSummaryBadge.spec.ts › Automated badge should appear on entity description with Automated source (shard 2, 1 retry)
  • Features/Permissions/GlossaryPermissions.spec.ts › Team-based permissions work correctly (shard 3, 1 retry)
  • Features/RestoreEntityInheritedFields.spec.ts › Validate restore with Inherited domain and data products assigned (shard 3, 2 retries)
  • Features/RestoreEntityInheritedFields.spec.ts › Validate restore with Inherited domain and data products assigned (shard 3, 1 retry)
  • Features/RTL.spec.ts › Verify Following widget functionality (shard 3, 1 retry)
  • Features/UserProfileOnlineStatus.spec.ts › Should show online status badge on user profile for active users (shard 3, 1 retry)
  • Flow/PersonaFlow.spec.ts › Set default persona for team should work properly (shard 3, 1 retry)
  • Pages/Customproperties-part2.spec.ts › entityReferenceList shows item count, scrollable list, no expand toggle (shard 4, 1 retry)
  • Pages/Domains.spec.ts › Multiple consecutive domain renames preserve all associations (shard 4, 1 retry)
  • Pages/Domains.spec.ts › Verify Domain entity API calls do not include invalid domains field in glossary term assets (shard 4, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › verify create lineage for entity - Topic (shard 6, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › verify create lineage for entity - Spreadsheet (shard 6, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › Verify opening config modal (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab IS visible for supported type: searchIndex (shard 6, 1 retry)
  • Pages/Lineage/PlatformLineage.spec.ts › Verify domain platform view (shard 6, 1 retry)
  • Pages/Users.spec.ts › Permissions for table details page for Data Consumer (shard 6, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant