Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Alias of group key is not returned correctly #186

Closed
Jianfei-Li opened this issue Sep 17, 2019 · 1 comment
Closed

Alias of group key is not returned correctly #186

Jianfei-Li opened this issue Sep 17, 2019 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Jianfei-Li
Copy link
Contributor

Query 1:

SELECT Dest es-table.Dest, COUNT(*) count, COUNT(DistanceKilometers) es-table.DistanceKilometers_count
  FROM kibana_sample_data_flights
  GROUP BY Dest
  ORDER BY Dest DESC
  LIMIT 2

The return is as below, in which the aggregation key returned is Dest instead of es-table.Dest

{
  "took": 3,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 10000,
      "relation": "gte"
    },
    "max_score": null,
    "hits": []
  },
  "aggregations": {
    "Dest": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 11842,
      "buckets": [
        {
          "key": "Zurich Airport",
          "doc_count": 691,
          "es-table.DistanceKilometers_count": {
            "value": 691
          },
          "count": {
            "value": 691
          }
        },
        {
          "key": "Xi'an Xianyang International Airport",
          "doc_count": 526,
          "es-table.DistanceKilometers_count": {
            "value": 526
          },
          "count": {
            "value": 526
          }
        }
      ]
    }
  }
}

Query 2:

SELECT date_format(timestamp, 'yyyy-MM') es-table.timestamp_tg, COUNT(*) count, COUNT(DistanceKilometers) es-table.DistanceKilometers_count
FROM kibana_sample_data_flights
GROUP BY date_format(timestamp, 'yyyy-MM')
ORDER BY date_format(timestamp, 'yyyy-MM') DESC
LIMIT 2500

The response is as below, in which the aggregation key returned is date_format_4 instead of the alias(es-table.timestamp_tg)

{
  "took": 145,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 10000,
      "relation": "gte"
    },
    "max_score": null,
    "hits": []
  },
  "aggregations": {
    "date_format_4": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "key": "2019-10",
          "doc_count": 6201,
          "es-table.DistanceKilometers_count": {
            "value": 6201
          },
          "count": {
            "value": 6201
          }
        },
        {
          "key": "2019-09",
          "doc_count": 6858,
          "es-table.DistanceKilometers_count": {
            "value": 6858
          },
          "count": {
            "value": 6858
          }
        }
      ]
    }
  }
}
@galkk
Copy link
Contributor

galkk commented Oct 2, 2019

Aliases are issue in general, see #117 as well

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants