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

Allow Bucket Script aggregation to reference on null #37862

Closed
larrycinnabar opened this issue Jan 25, 2019 · 3 comments
Closed

Allow Bucket Script aggregation to reference on null #37862

larrycinnabar opened this issue Jan 25, 2019 · 3 comments
Labels
:Analytics/Aggregations Aggregations :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement

Comments

@larrycinnabar
Copy link

related to #36642

related to #31920

Example:

  "some-items":{  
    "aggregations":{  
      "averaged":{  
        "avg":"field"
      }
    },
    "children":{  
      "type":"child"
    }
  },
  "some-metric":{  
    "bucket_script":{  
      "buckets_path":{  
        "a":"some-items>averaged.value"
      },
      "script":{  
        "source":"params.a + 100"
      }
    }
  }

If, in this example, number of child elements are zero, the AvgAggregation can't be performed (as averaging of zero elements is impossible). That averaged aggregation will return null.
But this null will silentry break the some-metric. In the final result, some-metric won't just appear (without any error).

I think it's a good thing to be able to handle these case inside the script. For example:

"source":"if (params.a == null) {return 100} else {return params.a + 100}"

In case if this null is not handled - elastic can just return an error

@larrycinnabar larrycinnabar changed the title Allow Bucket Script aggregation to reference on string results Allow Bucket Script aggregation to reference on null Jan 25, 2019
@cbuescher cbuescher added >enhancement :Analytics/Aggregations Aggregations :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache labels Jan 25, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@polyfractal
Copy link
Contributor

Yep, this is definitely a bug. I'm going to close though since it's being tracked in #27377, and in particular there's a plan that was discussed here: #27377 (comment)

The tl;dr: is that we would like to start passing the raw value to the script, but also pass in the doc_count. Both are important to provide, so that the user knows if the value is actually null, or if it's just null because there were no documents.

Thanks for opening the issue, and sorry you're running into this :( There are several related pipeline issues that revolve around missing docs / null values, so hopefully we can start tackling them soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement
Projects
None yet
Development

No branches or pull requests

4 participants