Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Nested Function With Sort Doesn't Sort Inner Hits #1788

Open
Tracked by #1872
forestmvey opened this issue Jun 27, 2023 · 1 comment
Open
Tracked by #1872

[BUG] Nested Function With Sort Doesn't Sort Inner Hits #1788

forestmvey opened this issue Jun 27, 2023 · 1 comment
Labels
bug Something isn't working legacy Issues related to legacy query engine to be deprecated

Comments

@forestmvey
Copy link
Collaborator

What is the bug?
Sorting on nested fields does not sort inner_hits of response.

Dataset:

{"index":{"_id":"1"}}
{"message":[{"info":"c"},{"info":"a"}]}
{"index":{"_id":"2"}}
{"message":{"info":"d"}}

Mapping:

{
  "mappings": {
    "properties": {
      "message": {
        "type": "nested",
        "properties": {
          "info": {
            "type": "keyword",
            "index": "true"
          }
        }
      }
    }
  }
}

Query:

SELECT nested(message.info) FROM nested_objects ORDER BY nested(message.info) DESC;

Response:

{
    "schema": [
        {
            "name": "message.info",
            "type": "keyword"
        }
    ],
    "total": 3,
    "datarows": [
        [
            "d"
        ],
        [
            "c"
        ],
        [
            "a"
        ]
    ],
    "size": 3,
    "status": 200
}

How can one reproduce the bug?
Steps to reproduce the behavior:

  1. Upload dataset with index mapping.
  2. Run SQL query.
  3. Verify Results.

What is the expected behavior?
The hits portion of the response is sorted, and the inner_hits portion is not sorted. The inner_hits could be sorted, but this would be two separate sorts and all returned data would not be one contiguous sort. Perhaps an in-memory solution may be the only fix here.

What is your host/environment?

  • OS: IOS
  • Version: 13.4.1
  • Plugins: SQL

Do you have any screenshots?
N/A

Do you have any additional context?
Legacy engine bug.

@forestmvey forestmvey added bug Something isn't working untriaged legacy Issues related to legacy query engine to be deprecated labels Jun 27, 2023
@Yury-Fridlyand
Copy link
Collaborator

Probably, we shouldn't push down sort if nested is present. This is similar to #1764. Could be done after optimizer rework described in #1752 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working legacy Issues related to legacy query engine to be deprecated
Projects
None yet
Development

No branches or pull requests

2 participants