question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Aggregations default field value

See original GitHub issue

I’m trying to generically build up aggregation queries and one thing I need to do is specify a default value of 0 for missing fields on my min,max and average aggregates. In 1.7.1, I don’t see the missing property and when I specify a script I can’t seem to set the value properly.

string defaultValueScript = $"_value != null ? _value : 0";
switch (field.Type) {
  case FieldAggregationType.Average:
    aggregation.Average(field.Key, a => a.Field(field.Field).Script(defaultValueScript));

Any ideas on how to accomplish this while still working once we migrate to 2.x

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
niemyjskicommented, Mar 29, 2016

bump

0reactions
niemyjskicommented, Mar 23, 2016

But what if you don’t know if it’s a field name or index? In our case it’s user supplied.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How set default values with fields in Aggregation results ...
Hi. Im using Elasticseach 6.4 following is my request. "aggs": { "times": { "date_histogram": { "field": "ccr.key", "interval": "…
Read more >
How to change default value size parameter of the terms ...
By default, the terms aggregation returns the top ten terms with the most documents. How to change default value of the size parameter...
Read more >
Google Data Studio Aggregation Explained
Count – Use this aggregation type when you want a field to be aggregated and displayed by default, as the total count of...
Read more >
Aggregation - Looker Studio Help
You can apply the following default aggregations to fields in data sources. Aggregation Method, Abbreviation, Description. Sum, SUM, The field values are added ......
Read more >
Aggregations
List of Aggregate Functions​ · Optional max parameter limits the number of values returned; if omitted, the default is 0 , meaning return...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found