Skip to content

Option to remove key_as_string from aggregation response #63898

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

Open
wylieconlon opened this issue Oct 19, 2020 · 8 comments
Open

Option to remove key_as_string from aggregation response #63898

wylieconlon opened this issue Oct 19, 2020 · 8 comments
Labels
:Analytics/Aggregations Aggregations >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@wylieconlon
Copy link

wylieconlon commented Oct 19, 2020

Formatted keys are not always needed when the original value is used by client code, but are always returned. If there were an option to remove the formatted values then we could reduce the total response size of ES queries by going from this type of response:

{
  ...
  "aggregations": {
    "sales_over_time": {
      "buckets": [
        {
          "key_as_string": "2015-01-01",
          "key": 1420070400000,
          "doc_count": 3
        },

to this:

{
  ...
  "aggregations": {
    "sales_over_time": {
      "buckets": [
        {
          "key": 1420070400000,
          "doc_count": 3
        },

One option that would be nice would be to have a parameter called "include_formatted": false on the date histogram and other aggregations that return formatted keys.

There are existing workarounds, but both workarounds have issues:

  • Using REST response filtering to remove the keys. This has issues because of a bug in response filtering.
  • Setting the format to a special character like _ will reduce some of the response size, but the response will still contain "key_as_string": "_" instead of being removed.

cc @polyfractal

@wylieconlon wylieconlon added >enhancement :Analytics/Aggregations Aggregations Team:Search Meta label for search team needs:triage Requires assignment of a team area label labels Oct 19, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (:Analytics/Aggregations)

@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Oct 19, 2020
@polyfractal polyfractal removed the needs:triage Requires assignment of a team area label label Oct 19, 2020
@nik9000 nik9000 added the good first issue low hanging fruit label Oct 19, 2020
@alishahusain
Copy link
Contributor

I'm a first time contributor to this project and would like to take on this issue

@javanna
Copy link
Member

javanna commented Oct 20, 2020

Just an idea: would it make sense to implement this based on the human flag that every API already supports?

@nik9000
Copy link
Member

nik9000 commented Oct 20, 2020

Just an idea: would it make sense to implement this based on the human flag that every API already supports?

I think that'd be breaking change. Its a good idea though!

It looks like we always have a guard for emitting these like if format != RAW {b.field("key_as_string", format.format(key)}. Maybe we already support this and you just have to request the raw format everywhere? I'm not sure if there is a way to request the raw format everywhere though. I'm willing to bet some of those guards were just copy and pasted from other aggs.

@javanna
Copy link
Member

javanna commented Oct 20, 2020

I think that'd be breaking change. Its a good idea though!

I see, because the human flag has a global default which is false and that would change the default behaviour of aggs.

@akshataj96
Copy link

akshataj96 commented Oct 20, 2020

Hi @wylieconlon @javanna ,
I can see that there are too many references for "key_as_string".
Can you give me some start point so that i can look further into this?

@not-napoleon
Copy link
Member

@akshataj96 & @alishahusain - As we looked deeper into this as a team, we found more complexity than we initially thought, and we've decided we need to address this internally. Sorry that we were a little too optimistic in labeling it good first issue. I encourage you to keep looking for issues you'd like to work on though!

@not-napoleon not-napoleon removed their assignment Mar 21, 2022
@javanna javanna removed the Team:Search Meta label for search team label Apr 26, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

9 participants