title: Is it possible to put the results of an ElasticSearch aggregation back into the index?
body: <p>So I have an index with ping data from host A to host B and my data looks like this:</p>
  
  <pre><code>{
    "@version" =&gt; "1",
    "@timestamp" =&gt; "2014-07-17T21:17:34.030Z",
    "host" =&gt; "host_a",
    "to_host" =&gt; "host_b",
    "value" =&gt; "25.6",
    "from_host" =&gt; "host_a",
    "stat_type" =&gt; "ping"
  }
  </code></pre>
  
  <p>The goal is to also store 90th percentile data for the value of the ping ("value" in the above) on a moving window e.g. last hour, last day etc.</p>
  
  <p>I know I can do this with an aggregation but my question is as follows:</p>
  
  <p>Does ElasticSearch support a way to automatically add the output of an aggregation (or query for that matter) back into the index?</p>
  
  <p>I know I could probably just take the output, tweak the fields and then put the data back in using some helper application but was curious as to if this is possible only using ES.</p>
  
  <p>To use an equivalent SQL example, I would be looking for something like this:</p>
  
  <pre><code>create table agg
  select id, count(*) as counts
  from data
  group by id;
  </code></pre>