title: How to use bucket selector aggregation with date range aggregation?
body: <p>Whenever I try to use bucket selector aggregate for date range aggregate I get this error.</p>
  <pre><code>buckets_path must reference either a number value or a single value numeric metric aggregation, got: [Object[]] at aggregation [agg1]
  
  </code></pre>
  <p>This is the query that is trying to get all the users (parent document) who have bought a particular product in the last 180 days with the total amount greater than, say 200. I want to filter out the parent documents which satisfy this aggregation.
  User(parent) &gt; transactions(child)</p>
  <pre><code>  &quot;aggs&quot;: {
      &quot;group_by_id&quot;: {
        &quot;composite&quot;: {
          &quot;sources&quot;: [
            {
              &quot;id&quot;: {
                &quot;terms&quot;: {
                  &quot;field&quot;: &quot;user_id&quot;
                }
              }
            }
          ]
        },
        &quot;aggs&quot;: {
          &quot;total_transactions&quot;: {
            &quot;children&quot;: {
              &quot;type&quot;: &quot;transaction_list&quot;
            },
            &quot;aggs&quot;: {
              &quot;range_bucket&quot;: {
                &quot;date_range&quot;: {
                  &quot;field&quot;: &quot;transaction_list.transaction_date&quot;,
                  &quot;ranges&quot;: [{
                    &quot;from&quot;: &quot;now-180d/d&quot;,
                    &quot;to&quot;: &quot;now&quot;,
                    &quot;key&quot;: &quot;bucket&quot;
                  }]
                },
                &quot;aggs&quot;: {
                  &quot;item_filter&quot;: {
                    &quot;filter&quot;: {
                      &quot;term&quot;: {
                        &quot;transaction_list.inventories.item_id&quot;: &quot;1234&quot;
                      }
                    },
                    &quot;aggs&quot;: {
                      &quot;item_total&quot;: {
                        &quot;sum&quot;: {
                          &quot;field&quot;: &quot;transaction_list.inventory_total&quot;
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          &quot;inventory_selector&quot;: {
            &quot;bucket_selector&quot;: {
              &quot;buckets_path&quot;: {
                &quot;total&quot;: &quot;total_transactions &gt; range_bucket &gt; item_filter &gt; item_total&quot;
              },
              &quot;script&quot;: &quot;params.total &gt; 200&quot;
            }
          }
        }
      }
    }
  </code></pre>