title: Elastic-search aggregate top 3 common result
body: <p>My indexed data is of below structure, i want to aggregate top 3 most repeted productProperty, so top 3 most repeated productProperty will be there in aggregation result</p>
  <pre><code>  [
      {
          productProperty: &quot;material&quot;,
          productValue:[{value: wood},{value: plastic}] ,
      },
      {
          productProperty: &quot;material&quot;,
          productValuea:[{value: wood},{value: plastic}] ,
      },
      {
          productProperty: &quot;type&quot;,
          productValue:[{value: 26A},{value: 23A}] ,
      },
      {
          productProperty: &quot;type&quot;,
          productValue:[{value: 22B},{value: 90C}] ,
      },
      {
          productProperty: &quot;material&quot;,
          productValue:[{value: wood},{value: plastic}] ,
      },
      {
          productProperty: &quot;age_rating&quot;,
          productValue:[{value: 18},{value: 13}] ,
      }
      ]
  </code></pre>
  <p>Below query aggregates all based on productProperty but how can i get top 3 results out of that</p>
  <pre><code>{
    &quot;query&quot;: {},
    &quot;aggs&quot;: {
      &quot;filtered_product_property&quot;: {
        &quot;filter&quot;: {
          &quot;bool&quot;: {
            &quot;must&quot;: []
          }
        },
        &quot;aggs&quot;: {
          &quot;aggs&quot;: {
            &quot;productProperty&quot;: {
              &quot;terms&quot;: {
                &quot;field&quot;: &quot;productProperty&quot;
              }
            }
          }
        }
      }
    }
  }
  </code></pre>