title: How to set up percolator to return when an aggregation value hits a certain threshold?
body: <p>Take the following aggregation query as an example:</p>
  
  <pre><code>{
    "query": {
      "match_all": {}
    },
    "aggs": {
      "groupBy": {
        "terms": {
          "field": "CustomerName"
        },
        "aggs": {
          "points_sum": {
            "stats": {
              "field": "TransactionAmount"
            }
          }
        }
      }
    },
    "size": 0
  }
  </code></pre>
  
  <p>I am interested in knowing when any CustomerName has an average TransactionAmount (stats.avg) that is above some threshold for all of that customer's purchases, as soon as I index a document that would put my average above that threshold. It seems like percolator is designed for matching documents to rules, more or less, but I can't find any good examples of using percolator to match rules that are based on aggregation results.</p>
  
  <p>Is this possible? Is percolator the best solution here? Is there another/better solution? Thanks in advance </p>