<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Max_bucket on INFINI Pizza</title><link>https://pizza.rs/tags/max_bucket/</link><description>Recent content in Max_bucket on INFINI Pizza</description><generator>Hugo</generator><language>en</language><atom:link href="https://pizza.rs/tags/max_bucket/index.xml" rel="self" type="application/rss+xml"/><item><title>Max bucket aggregation</title><link>https://pizza.rs/docs/references/aggregation/pipeline/max-bucket/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://pizza.rs/docs/references/aggregation/pipeline/max-bucket/</guid><description>&lt;h1 id="max-bucket-aggregation">
 Max bucket aggregation
 &lt;a class="anchor" href="#max-bucket-aggregation">#&lt;/a>
&lt;/h1>
&lt;p>A sibling pipeline aggregation identifying the &lt;strong>largest&lt;/strong> per-bucket
metric value — e.g. the best-performing group. Bucket aggregations can
sort their own output, but only inside one request&amp;rsquo;s bucket list;
&lt;code>max_bucket&lt;/code> lifts the winning number out as a single headline metric
next to the breakdown.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="s2">&amp;#34;best_seller&amp;#34;&lt;/span>&lt;span class="err">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;max_bucket&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;buckets_path&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;per_type&amp;gt;revenue&amp;#34;&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="how-it-works">
 How it works
 &lt;a class="anchor" href="#how-it-works">#&lt;/a>
&lt;/h2>
&lt;p>&lt;code>max_bucket&lt;/code> is declared &lt;strong>next to&lt;/strong> the bucket aggregation it consumes
and runs after every regular aggregation — including the distributed
merge — has finished. It walks the parent&amp;rsquo;s finished buckets, collects
one number per bucket, and returns their maximum as a single-value
metric (&lt;code>{&amp;quot;value&amp;quot;: 1800}&lt;/code>) placed alongside the parent. Only the value
is returned — not which bucket produced it; read the parent&amp;rsquo;s bucket
list (or sort it with 
 &lt;a href="https://pizza.rs/docs/references/aggregation/pipeline/bucket-sort/">&lt;code>bucket_sort&lt;/code>&lt;/a>) when you need
the winner&amp;rsquo;s key.&lt;/p></description></item></channel></rss>