# Aggregations 1.1.1 to 1.7.3 different results on Arrays

**URL:** <https://discuss.elastic.co/t/aggregations-1-1-1-to-1-7-3-different-results-on-arrays/35307>\
**Category:** Elasticsearch\
**Created:** [November 23, 2015, 1:40pm UTC](https://discuss.elastic.co/t/aggregations-1-1-1-to-1-7-3-different-results-on-arrays/35307 "2015-11-23T13:40:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wockan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wockan/32/6101_2.png) [@wockan](https://discuss.elastic.co/u/wockan)\
**Post date:** [November 23, 2015, 1:40pm UTC](https://discuss.elastic.co/t/aggregations-1-1-1-to-1-7-3-different-results-on-arrays/35307/1 "2015-11-23T13:40:57Z")

</div>

Hi,

We have a problem with aggregations since we upgraded from 1.1.1 to 1.7.3 (yeah it's a bit of a huge jump)

what we want is to group by user and get the doc count

in 1.1.1 we filtered by

users.id = 1  
aggregation term users.id

we got:  
"key": 1  
"doc\_count:" 3

in 1.7.3  
we get:  
"key": DOC ID  
"doc\_count:" 1

"key": DOC ID  
"doc\_count:" 1

"key": DOC ID  
"doc\_count:" 1

this happens only to Arrays (not nested) and not inner objects.

> {  
> "query": {  
> "filtered": {  
> "filter": {  
> "bool": {  
> "must": [  
> {  
> "terms": {  
> "users.id": [  
> "160"  
> ]  
> }  
> }  
> ]  
> }  
> }  
> }  
> },  
> "aggs": {  
> "users\_group": {  
> "terms": {  
> "field":"users.id"  
> }  
> }  
> },  
> "size": 0  
> }

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [November 23, 2015, 3:24pm UTC](https://discuss.elastic.co/t/aggregations-1-1-1-to-1-7-3-different-results-on-arrays/35307/2 "2015-11-23T15:24:57Z")

</div>

Can you provide us with an example that reproduces the issue?

---

<div class="post-metadata">

**Author:** ![wockan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wockan/32/6101_2.png) [@wockan](https://discuss.elastic.co/u/wockan)\
**Post date:** [November 24, 2015, 1:30pm UTC](https://discuss.elastic.co/t/aggregations-1-1-1-to-1-7-3-different-results-on-arrays/35307/3 "2015-11-24T13:30:43Z")

</div>

Hello here you go

Query:

```javascript
{
    "query": {
        "filtered": {
           "filter": {
               "bool": {
               "must": [
                 {
                     "terms": {
                         "users.id": [
                            "160"
                         ]
                      }
                  }
               ]
               }
           }
        }
    }, 
    "aggs": {
        "users_group": {
            "terms": {
                "field":"users.id"
                
            }
        }
    },
    "size": 0 
}

```

Mapping:  
had to shorten the mapping a bit because 5000 max limit forum.  
Hopefully nothing relating 🙂

```javascript
{
   "spcrm_0": {
      "mappings": {
         "activities": {
            "_id": {
               "path": "id"
            },
            "_parent": {
               "type": "clients"
            },
            "_routing": {
               "required": true
            },
            "properties": {
               "activityType": {
                  "properties": {
                     "id": {
                        "type": "long"
                     },
                     "name": {
                        "type": "string",
                        "index": "no",
                        "fields": {
                           "description": {
                              "type": "string"
                           },
                           "query": {
                              "type": "string",
                              "analyzer": "analyzer_startswith"
                           }
                        }
                     }
                  }
               },
               "client": {
                  "properties": {
                     "id": {
                        "type": "long"
                     },
                     "name": {
                        "type": "string",
                        "fields": {
                           "query": {
                              "type": "string",
                              "analyzer": "analyzer_startswith"
                           }
                        }
                     },
                     "phone": {
                        "type": "string"
                     }
                  }
               },
               "closeDate": {
                  "type": "date",
                  "format": "dateOptionalTime"
               },
               "contacts": {
                  "properties": {
                     "cellPhone": {
                        "type": "string"
                     },
                     "id": {
                        "type": "long"
                     },
                     "name": {
                        "type": "string",
                        "fields": {
                           "query": {
                              "type": "string",
                              "analyzer": "analyzer_startswith"
                           }
                        }
                     },
                     "phone": {
                        "type": "string"
                     }
                  }
               },
               "date": {
                  "type": "date",
                  "format": "dateOptionalTime"
               },
               "description": {
                  "type": "string",
                  "fields": {
                     "query": {
                        "type": "string",
                        "analyzer": "analyzer_startswith"
                     }
                  }
               },
               "id": {
                  "type": "long"
               },
               "users": {
                  "properties": {
                     "email": {
                        "type": "string"
                     },
                     "id": {
                        "type": "long"
                     },
                     "name": {
                        "type": "string",
                        "fields": {
                           "query": {
                              "type": "string",
                              "analyzer": "analyzer_startswith"
                           }
                        }
                     }
                  }
               }
            }
         }
      }
   }
}

```

---

<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 5, 2017, 11:36pm UTC](https://discuss.elastic.co/t/aggregations-1-1-1-to-1-7-3-different-results-on-arrays/35307/4 "2017-07-05T23:36:15Z")

</div>


