# I have some problem with combined aggreagation avg with a given candation

**URL:** <https://discuss.elastic.co/t/i-have-some-problem-with-combined-aggreagation-avg-with-a-given-candation/21128>\
**Category:** Elasticsearch\
**Created:** [December 8, 2014, 1:00am UTC](https://discuss.elastic.co/t/i-have-some-problem-with-combined-aggreagation-avg-with-a-given-candation/21128 "2014-12-08T01:00:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mengjiqi\_Fisnik](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@Mengjiqi\_Fisnik](https://discuss.elastic.co/u/Mengjiqi_Fisnik)\
**Post date:** [December 8, 2014, 1:00am UTC](https://discuss.elastic.co/t/i-have-some-problem-with-combined-aggreagation-avg-with-a-given-candation/21128/1 "2014-12-08T01:00:49Z")

</div>

Define average age of the users with name "Jone"

{

```
        "query" : {
    "match" : { "name" : "Jone" }
      },

        "aggs" : {
            "avg_age" : { "avg" : { "field" : "age" } }
        }    

```

}

This request hits all item with names Jone, but do not calculate average.  
Aggregation avg display 0.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 8, 2014, 3:22am UTC](https://discuss.elastic.co/t/i-have-some-problem-with-combined-aggreagation-avg-with-a-given-candation/21128/2 "2014-12-08T03:22:04Z")

</div>

May be a full SENSE example as a GIST would help understand what you are doing?  
Age is a String?

David

> Le 8 déc. 2014 à 02:00, Mengjiqi Fisnik [fisnikmengjiqi1990@gmail.com](mailto:fisnikmengjiqi1990@gmail.com) a écrit :
> 
> Define average age of the users with name "Jone"
> 
> {
> 
> ```
> "query" : {
> "match" : { "name" : "Jone" }
> },
> 
> "aggs" : {
> "avg_age" : { "avg" : { "field" : "age" } }
> }    
> 
> ```
> 
> }
> 
> This request hits all item with names Jone, but do not calculate average. Aggregation avg display 0.
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/10BB0898-865B-4192-B42C-F27DD5EAB42D%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/10BB0898-865B-4192-B42C-F27DD5EAB42D%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Mengjiqi\_Fisnik](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@Mengjiqi\_Fisnik](https://discuss.elastic.co/u/Mengjiqi_Fisnik)\
**Post date:** [December 8, 2014, 5:22pm UTC](https://discuss.elastic.co/t/i-have-some-problem-with-combined-aggreagation-avg-with-a-given-candation/21128/3 "2014-12-08T17:22:19Z")

</div>

Thank you David, I try to explain better.

[http://localhost/ctweets/tweet/\_search](http://localhost/ctweets/tweet/_search)

Query: Define average age of users that have name ''Fisnik".

I tried query that i write above but it does not calculated average age of  
users with name "Fisnik".  
Shows me all users with name :Fisnik", but in "Aggregations" in avg shows  
value=0;

I

On Monday, December 8, 2014 4:22:13 AM UTC+1, David Pilato wrote:

> May be a full SENSE example as a GIST would help understand what you are  
> doing?  
> Age is a String?
> 
> David
> 
> Le 8 déc. 2014 à 02:00, Mengjiqi Fisnik \<[fisnikmen...@gmail.com](mailto:fisnikmen...@gmail.com)  
> \<javascript:\>\> a écrit :
> 
> Define average age of the users with name "Jone"
> 
> {
> 
> ```
> "query" : {
> "match" : { "name" : "Jone" }
> },
> 
> "aggs" : {
> "avg_age" : { "avg" : { "field" : "age" } }
> }    
> 
> ```
> 
> }
> 
> This request hits all item with names Jone, but do not calculate average.  
> Aggregation avg display 0.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4cec7460-337f-4eb7-9d08-4ac19f96ac19%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4cec7460-337f-4eb7-9d08-4ac19f96ac19%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 8, 2014, 5:31pm UTC](https://discuss.elastic.co/t/i-have-some-problem-with-combined-aggreagation-avg-with-a-given-candation/21128/4 "2014-12-08T17:31:59Z")

</div>

I understood what you want.  
I did not understand what you did.

From what I read, your query sounds good to me.

As it does not work for you, I think you should provide a full example which reproduces your issue: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help/) [http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/)

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 8 déc. 2014 à 18:22, Mengjiqi Fisnik [fisnikmengjiqi1990@gmail.com](mailto:fisnikmengjiqi1990@gmail.com) a écrit :
> 
> Thank you David, I try to explain better.
> 
> [http://localhost/ctweets/tweet/\_search](http://localhost/ctweets/tweet/_search)
> 
> Query: Define average age of users that have name ''Fisnik".
> 
> I tried query that i write above but it does not calculated average age of users with name "Fisnik".  
> Shows me all users with name :Fisnik", but in "Aggregations" in avg shows value=0;
> 
> I
> 
> On Monday, December 8, 2014 4:22:13 AM UTC+1, David Pilato wrote:  
> May be a full SENSE example as a GIST would help understand what you are doing?  
> Age is a String?
> 
> David
> 
> Le 8 déc. 2014 à 02:00, Mengjiqi Fisnik \<[fisnikmen...@gmail.com](mailto:fisnikmen...@gmail.com) \<javascript:\>\> a écrit :
> 
> > Define average age of the users with name "Jone"
> > 
> > {
> > 
> > ```
> > "query" : {
> > "match" : { "name" : "Jone" }
> > },
> > 
> > "aggs" : {
> > "avg_age" : { "avg" : { "field" : "age" } }
> > }    
> > 
> > ```
> > 
> > }
> > 
> > This request hits all item with names Jone, but do not calculate average. Aggregation avg display 0.
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/46076a0f-daf1-4373-8f3f-94d67dc82d53%40googlegroups.com?utm_medium=email&utm_source=footer).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com) [mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4cec7460-337f-4eb7-9d08-4ac19f96ac19%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4cec7460-337f-4eb7-9d08-4ac19f96ac19%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/4cec7460-337f-4eb7-9d08-4ac19f96ac19%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/4cec7460-337f-4eb7-9d08-4ac19f96ac19%40googlegroups.com?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/126C4835-9848-4196-BDDF-B4C527CBAAF3%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/126C4835-9848-4196-BDDF-B4C527CBAAF3%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:44am UTC](https://discuss.elastic.co/t/i-have-some-problem-with-combined-aggreagation-avg-with-a-given-candation/21128/5 "2017-07-06T00:44:54Z")

</div>


