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

fix 'buckets' value may be a dict #1

Open
wants to merge 1 commit into
base: elasticsearch-query-fix
Choose a base branch
from

Conversation

ivanli1990
Copy link

@ivanli1990 ivanli1990 commented May 21, 2019

What type of PR is this? (check all applicable)

  • Bug Fix

Description

The 'buckets' object in elasticsearch aggregations may be not a list but a dict

Related Tickets & Documents

#2789

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

@lkm
Copy link
Owner

lkm commented May 21, 2019

Great thanks @ivanli1990! Has this got to do with using numbered instead of named aggregation names?Maybe we should add a test case for this result?

@ivanli1990
Copy link
Author

Great thanks @ivanli1990! Has this got to do with using numbered instead of named aggregation names?Maybe we should add a test case for this result?

Numbered aggregation name is no matter, but there still some issue with multiple buckets result:

{
  "took": 3,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 47,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "3": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "1": {
            "value": 15
          },
          "4": {
            "buckets": {
              "state:已关闭": {
                "1": {
                  "value": 11
                },
                "5": {
                  "doc_count_error_upper_bound": 0,
                  "sum_other_doc_count": 0,
                  "buckets": [
                    {
                      "1": {
                        "value": 10
                      },
                      "key": "数据自身问题",
                      "doc_count": 10
                    },
                    {
                      "1": {
                        "value": 1
                      },
                      "key": "未填写原因",
                      "doc_count": 1
                    }
                  ]
                },
                "doc_count": 11
              }
            }
          },
          "key": "数据",
          "doc_count": 15
        },
        {
          "1": {
            "value": 9
          },
          "4": {
            "buckets": {
              "state:已关闭": {
                "1": {
                  "value": 8
                },
                "5": {
                  "doc_count_error_upper_bound": 0,
                  "sum_other_doc_count": 0,
                  "buckets": [
                    {
                      "1": {
                        "value": 8
                      },
                      "key": "未填写原因",
                      "doc_count": 8
                    }
                  ]
                },
                "doc_count": 8
              }
            }
          },
          "key": "多码后端",
          "doc_count": 32
        }
      ]
    }
  }
}

@lkm
Copy link
Owner

lkm commented May 22, 2019

Alright if I could get you to please finish the test (there are no assertions now, it's fine that it would be failing), then I'll try to dig into it again

@ivanli1990 ivanli1990 force-pushed the elasticsearch-query-fix-buckets branch from 786928b to 489847a Compare May 23, 2019 09:22
@ivanli1990
Copy link
Author

ivanli1990 commented May 23, 2019

Alright if I could get you to please finish the test (there are no assertions now, it's fine that it would be failing), then I'll try to dig into it again

hi lkm,
I added 2 cases in test, and I wrote the expect rows and columns in each test case, it's just the result I expected, sort of each row in rows(same in column in columns) maybe different from the actual rows and columns which parse with query result. So, you could just follow the expect rows and columns as a reference.
In addtion, I think 'doc_count_error_upper_bound' and 'sum_other_doc_count' fileds in elasticsearch query result should not be display on redash, user not care these fileds, so they should not add in rows and columns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants