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

Kibana: Array Values are by default sorting instead of printing as is. #99628

Closed
kanika-singla opened this issue May 10, 2021 · 5 comments
Closed
Labels
blocked bug Fixes for quality problems that affect the customer experience Feature:Lens impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@kanika-singla
Copy link

kanika-singla commented May 10, 2021

Kibana version: v7

Original install method (e.g. download page, yum, from source, etc.): I am using company infrastructure deployment.

Describe the bug: I am trying to show the field which is nested array (nestedResults), on Kibana (Lens) it is sorting the array values when displaying it on the dashboard (Lens visualization). I am breaking the nested array on the unique field values.

Steps to reproduce:

  1. Have logs ready in elastic with array containing some values- repetitive, strings, numbers.
  2. Create a dashboard in Kibana
  3. Create a Lens visualization -> Data Table -> Select the field containing array values
  4. It will show as sorted field value

Expected behavior: The values of array print as is on Kibana and should not sort the values.

Screenshots (if relevant):
image

image

Any additional context:
https://discuss.elastic.co/t/kibana-sorting-out-array-values/272266

@kanika-singla kanika-singla added the bug Fixes for quality problems that affect the customer experience label May 10, 2021
@botelastic botelastic bot added the needs-team Issues missing a team label label May 10, 2021
@marius-dr marius-dr added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label May 10, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@botelastic botelastic bot removed the needs-team Issues missing a team label label May 10, 2021
@flash1293
Copy link
Contributor

This is a limitation of how the top hits agg config works today. It's happening because we are fetching these from the docvalues which seem to not preserve the original order in Elasticsearch.

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

@exalate-issue-sync exalate-issue-sync bot added impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort labels Jun 21, 2021
@flash1293
Copy link
Contributor

This will be fixed by #103279

Right now in these cases docvalues are used which are not preserving the original order.

POST mytest/_doc
{
  "a": ["z", "y", "x"],
  "ts": "2021-06-28"
}

GET mytest/_search
{
  "size": 0,
  "aggs": {
    "h": {
      "top_hits": {
        "size": 1,
        "docvalue_fields": ["a.keyword"],
        "sort": [
          {
            "ts": {
              "order": "desc"
            }
          }
        ]
      }
    }
  }
}

returns

{
            "_index" : "mytest",
            "_id" : "VXmvUXoBaek9z0nub3ei",
            "_score" : null,
            "_source" : {
              "a" : [
                "z",
                "y",
                "x"
              ],
              "ts" : "2021-06-28"
            },
            "fields" : {
              "a.keyword" : [
                "x",
                "y",
                "z"
              ]
            },
            "sort" : [
              1624838400000
            ]
          }

However using fields like this:

GET mytest/_search
{
  "size": 0,
  "aggs": {
    "h": {
      "top_hits": {
        "size": 1,
        "fields": ["a.keyword"],
        "sort": [
          {
            "ts": {
              "order": "desc"
            }
          }
        ]
      }
    }
  }
}

will return this:

{
            "_index" : "mytest",
            "_id" : "VXmvUXoBaek9z0nub3ei",
            "_score" : null,
            "_source" : {
              "a" : [
                "z",
                "y",
                "x"
              ],
              "ts" : "2021-06-28"
            },
            "fields" : {
              "a.keyword" : [
                "z",
                "y",
                "x"
              ]
            },
            "sort" : [
              1624838400000
            ]
          }

@flash1293
Copy link
Contributor

Fixed by #103279

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked bug Fixes for quality problems that affect the customer experience Feature:Lens impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

No branches or pull requests

4 participants