serhiy-bzhezytskyy opened a new issue, #68:
URL: https://github.com/apache/solr-orbit/issues/68

   ### Describe the bug
   
   `convert-workload` translates an OpenSearch `range` query in 
`_translate_query_node`
   (`solrorbit/conversion/query.py:181`). It folds `gt` into `gte` and `lt` 
into `lte`, then always emits
   square brackets:
   
   ```python
   lo = bounds.get("gte", bounds.get("gt", "*"))
   hi = bounds.get("lte", bounds.get("lt", "*"))
   ...
   return f"{field}:[{lo} TO {hi}]"
   ```
   
   Solr supports both spellings — `[a TO b]` and `[a TO b}` — so the exclusive 
form is available and simply
   not produced. Every converted range therefore comes out inclusive at both 
ends, and a workload's
   exclusive bound silently becomes an inclusive one.
   
   The converted operation still returns a latency number, which is why a 
benchmark run cannot notice it:
   it answers a wider question than the operation it was converted from.
   
   ### To reproduce
   
   ```bash
   solr-orbit convert-workload \
     --workload-path=<opensearch-benchmark-workloads>/nyc_taxis \
     --output-path=/tmp/nyc_taxis
   grep -A 3 '"name": "range"' /tmp/nyc_taxis/operations/default.json
   ```
   
   Upstream's body is
   
   ```json
   {"range": {"total_amount": {"gte": 5, "lt": 15}}}
   ```
   
   and the conversion produces
   
   ```json
   {"query": "total_amount:[5 TO 15]"}
   ```
   
   Measured against a Solr collection holding `documents-1k.json`, the corpus 
`--test-mode` downloads:
   
   | query | numFound |
   |---|---:|
   | `total_amount:[5 TO 15]` | **576** |
   | `total_amount:[5 TO 15}` | **573** |
   
   The three extra documents are exactly those with `total_amount == 15`:
   
   ```
   total_amount 15.0, trip_distance  0.13, pickup 2015-01-01T00:35:03Z
   total_amount 15.0, trip_distance 19.79, pickup 2015-01-01T00:36:51Z
   total_amount 15.0, trip_distance  3.63, pickup 2015-01-01T00:38:45Z
   ```
   
   On a 300,649-document sample of the same corpus the difference is 191,735 
against 191,441 — 294
   documents. Querying OpenSearch with its own body and only `lt` changed to 
`lte` gives the same two
   numbers, so this is a property of the bound and not of either engine.
   
   ### Expected behavior
   
   `gte`/`lte` should translate to `[` / `]` and `gt`/`lt` to `{` / `}`, so the 
converted operation selects
   the same documents as the operation it was converted from. An absent bound 
is `*`, which has nothing to
   exclude and keeps the square bracket.
   
   | OpenSearch | expected Solr |
   |---|---|
   | `{"gte": 5, "lte": 15}` | `[5 TO 15]` |
   | `{"gte": 5, "lt": 15}` | `[5 TO 15}` |
   | `{"gt": 5, "lte": 15}` | `{5 TO 15]` |
   | `{"gt": 5, "lt": 15}` | `{5 TO 15}` |
   | `{"gte": 5}` | `[5 TO *]` |
   | `{"lt": 15}` | `[* TO 15}` |
   
   ### Host / Environment
   
   Solr 9.10.1 (`solr:latest`), macOS 15 arm64, Python 3.12. Not 
environment-dependent: the translation is
   pure string construction and reproduces from `convert-workload` alone.
   
   ### Additional context
   
   `tests/unit/solr/test_workload_converter.py::test_range_query` is green over 
this, for two independent
   reasons — either of which is enough on its own:
   
   1. it exercises `{"gte": 5, "lte": 100}`, the one combination the current 
code gets right, and
   2. it asserts with `assertIn("fare_amount", …)` and `assertIn("TO", …)`, 
which pass for `[5 TO 100]`,
      `[5 TO 100}` and `{5 TO 100}` alike — so it could not see the brackets 
even against a wrong bound.
   
   The shipped `nyc_taxis` workload carries the resulting bound today
   (`nyc_taxis/operations/default.json`), so the fix has two halves: this one, 
and the workload file in
   `apache/solr-orbit-workloads`.
   


-- 
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