serhiy-bzhezytskyy commented on code in PR #180:
URL: https://github.com/apache/solr-orbit/pull/180#discussion_r4767118977


##########
solrorbit/conversion/workload_converter.py:
##########
@@ -750,6 +750,26 @@ def replace(match):
     return _MERGE_WAIT_OBJECT.sub(replace, text)
 
 
+def _convert_scroll(op: dict) -> None:
+    """
+    Rewrite a search with ``pages`` as a ``paginated-search``, which pages 
with Solr's cursorMark.
+
+    The query becomes ``q`` (and its filters ``fq``); no ``fl`` is set, so 
every stored field comes back as OpenSearch
+    returns ``_source``. A cursor needs a sort ending with the uniqueKey: 
upstream's sort gets ``id asc`` appended, and a
+    search without one is sorted by ``id asc``. OpenSearch's scroll orders by 
score and then index order, which a cursor
+    cannot use (``_docid_`` is refused).
+    """
+    body = op.pop("body")
+    translated = translate_to_solr_json_dsl(body)
+    op["operation-type"] = "paginated-search"
+    op["q"] = translated["query"]
+    if translated.get("filter"):
+        op["fq"] = translated["filter"]
+    sort = translated.get("sort")
+    op["sort"] = "id asc" if not sort else (sort if 
re.search(r"(^|,)\s*id\s+(asc|desc)\s*$", sort) else sort + ",id asc")

Review Comment:
   Confirmed on Solr 10.1.0: `sort=_doc,id asc` with a `cursorMark` returns 
400. The cursor orders by the unique key and Solr refuses its internal document 
order, so the `_doc` clause is dropped now (54c9f666). A bare field name 
without a direction fails the same way in an ordinary search, because the 
shared sort translator emits it as is, so that is left for a change to the 
translator. None of the four upstream scroll operations sets a sort.
   



##########
solrorbit/conversion/workload_converter.py:
##########
@@ -898,6 +918,11 @@ def _convert_operation(op, issues, skipped, source_dir, 
output_dir):
         if setup:
             op.update(setup)
 
+    # A search paged with pages / results-per-page is OpenSearch Benchmark's 
scroll: Solr pages with a cursor
+    if op_type == "search" and "pages" in op and 
_is_opensearch_body(op.get("body")):
+        _convert_scroll(op)
+        return True

Review Comment:
   A search with `pages` and no `body` is not valid in OpenSearch Benchmark: 
its `search` runner reads `body` with `mandatory(params, "body", ...)` 
(`osbenchmark/worker_coordinator/runner.py:1400`) and raises a `DataError`. 
There is nothing to convert, and the four upstream scroll operations all carry 
a body.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to