Skip to content

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

@forestmvey

Description

@forestmvey

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglegacyIssues related to legacy query engine to be deprecated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions