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.

Bucket and KeyItem dto's have been removed.

See original GitHub issue

I was curious what these were renamed too

        private static AggregationResult ToAggregationResult(this Bucket bucket, string field) {
            return new AggregationResult {
                Field = field,
                Terms = new AggregationDictionary<AggregationResult>(bucket.Items.OfType<KeyItem>().ToDictionary(t => t.Key, t => {
                    var termRes = new AggregationResult<AggregationResult> {
                        Total = t.DocCount
                    };

                    if (t.Aggregations?.Count > 0) {
                        termRes.Aggregations = new List<AggregationResult>();
                        foreach (var key in t.Aggregations.Keys) {
                            var nestedBucket = t.Aggregations[key] as Bucket;
                            if (nestedBucket == null)
                                continue;

                            termRes.Aggregations.Add(nestedBucket.ToAggregationResult(key));
                        }
                    }

                    return termRes;
                })),
            };
        }

        public static IReadOnlyCollection<AggregationResult> ToAggregationResult<T>(this ISearchResponse<T> response) where T : class {
            var result = new List<AggregationResult>();
            if (response.Aggregations == null || response.Aggregations.Count == 0)
                return result;

            foreach (var key in response.Aggregations.Keys) {
                var bucket = response.Aggregations[key] as Bucket;
                if (bucket == null)
                    continue;

                result.Add(bucket.ToAggregationResult(key));
            }

            return result;
        }

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
Mpdreamzcommented, Sep 28, 2016

You can also use the https://github.com/elastic/elasticsearch-net/blob/master/src/Nest/Aggregations/Visitor/AggregationVisitor.cs to do something more generic to a whole bunch of them.

1reaction
gmarzcommented, Sep 28, 2016

KeyItem is now KeyedBucket

Bucket is now BucketAggregate, which is an unfortunate intermediate object we need for deserialization (see #1792). Just a heads up, if #2081 is ever merged, it’ll be removed since we won’t need it anymore.

Seems like IBucket interface should have DocCount?

Not all buckets in ES return a doc_count, so it would be a bad abstraction for it to be on the base of all bucket types in NEST.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Art of Multiprocessor Programming, Revised Reprint
swapped from disk to memory, and smaller units of memory are being moved in and out of a hierarchy of processor caches. This...
Read more >
Untitled
The loop half of a key is an item dropped by numerous NPCs. tooth half of key, ... A lot of runescape players...
Read more >
ALTERNATE RAFFLE FORMATS
b) Purchaser removes individual tickets or coupons from his/her packet and chooses which bucket to place the ticket or coupon in. Each bucket...
Read more >
Report - Senate Intelligence Committee
On April 3,2014,1 announced that the full classified report had been updated and that the. Committee had voted to send the updated Executive ......
Read more >
Oracle® Retail Value Chain Collaboration
Time Periods – Each column represents a time bucket (e.g.daily or ... To delete a file that has been extracted with the Extracts...
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