# Elasticsearch aggregate Query from logstash

**URL:** <https://discuss.elastic.co/t/elasticsearch-aggregate-query-from-logstash/107543>\
**Category:** Logstash\
**Created:** [November 14, 2017, 11:46am UTC](https://discuss.elastic.co/t/elasticsearch-aggregate-query-from-logstash/107543 "2017-11-14T11:46:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranjith](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@ranjith](https://discuss.elastic.co/u/ranjith)\
**Post date:** [November 14, 2017, 11:46am UTC](https://discuss.elastic.co/t/elasticsearch-aggregate-query-from-logstash/107543/1 "2017-11-14T11:46:27Z")

</div>

Hi All,

I want to aggregate an index in elasticsearch using logstash and store that aggregate result in another index.

```auto
input {
  elasticsearch {
    hosts => "http://50.254.92.204:9200" 
    user => "elastic"
    password => "changeme"	
    index => "students"
    query => '{"query" : {"constant_score" : {"filter" : {"match" : { "name" : "Vinoth" }}}},"size": 0,"aggs": {"Vinoth_avg_marks": {"avg" : { "field" : "mark" } }}}'
	size => 500 
    scroll => "5m" 
    docinfo => true
  }
}

filter {

}
output {

  stdout { codec => rubydebug } 

  elasticsearch {
    hosts => "50.254.92.204:9200" 
    user => "elastic"
    password => "changeme"	  
    index => "test" 
    document_type => "test"
    #document_id => "%{[@metadata][_id]}"
  }
}

```

But aggregate result is not being pushed into the test index.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![ranjith](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@ranjith](https://discuss.elastic.co/u/ranjith)\
**Post date:** [November 16, 2017, 8:55am UTC](https://discuss.elastic.co/t/elasticsearch-aggregate-query-from-logstash/107543/2 "2017-11-16T08:55:17Z")

</div>

Hi all,

Any update on this ...  
Please guide me whether this is possible in logstash or not...Or I may be missing something  
Let me know as soon as possible

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 14, 2017, 8:55am UTC](https://discuss.elastic.co/t/elasticsearch-aggregate-query-from-logstash/107543/3 "2017-12-14T08:55:43Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
