Skip to content

Translate search_after into a cursorMark built from the sort values - #181

Open
serhiy-bzhezytskyy wants to merge 3 commits into
apache:mainfrom
serhiy-bzhezytskyy:search-after-to-cursor-mark
Open

serhiy-bzhezytskyy wants to merge 3 commits into
apache:mainfrom
serhiy-bzhezytskyy:search-after-to-cursor-mark

Conversation

@serhiy-bzhezytskyy

@serhiy-bzhezytskyy serhiy-bzhezytskyy commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

A converted search_after kept its sort but lost the values, so the operation fetched the first page instead of the page after them. Solr starts a cursor at given sort values when the cursorMark encodes them: Base64 of the JavaBin list of one value per sort clause (CursorMark#getSerializedTotem).

The converter now:

  • builds that mark from the values;
  • appends id to the sort in the direction of the last clause;
  • adds a tie-break value that sorts after (asc) or before (desc) every id, so documents equal to the values are skipped as OpenSearch skips them.

Only plong sort fields with non-negative values are carried, the case compared with OpenSearch. Anything else is reported in CONVERTED.md.

An explicit track_total_hits is carried as minExactCount: false becomes 1, the threshold OpenSearch hands Lucene, and a number is kept. A search that does not state it is unchanged.

For geonames' three operations the converter now writes the bodies of apache/solr-orbit-workloads#32. On a 1,000,436-document sample, three consecutive pages of each give the same ids in the same order as OpenSearch's search_after: 300, 212 (the whole result) and 300. The new tests fail without the change.

A converted search_after kept its sort but lost the values, so the operation fetched the first page instead of the page after them. Solr starts a cursor at given sort values when the cursorMark encodes them: Base64 of the JavaBin list of one value per sort clause. The converter now builds that mark, appends id to the sort in the direction of the last clause, and adds a tie-break value that sorts after (asc) or before (desc) every id, so documents equal to the values are skipped as OpenSearch skips them. Only plong sort fields with non-negative values are carried; anything else is reported in CONVERTED.md.
A search that tells OpenSearch not to count, or to count up to a number, did the full exact count in Solr, which is more work than the search it is compared with. Solr's minExactCount reaches the same Lucene threshold: false becomes 1, which Lucene raises to the number of rows as OpenSearch's does, and a number is carried as it is. A search that does not state it keeps Solr's default.
# Conflicts:
#	solrorbit/conversion/workload_converter.py

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant