Doc_count on aggregations doesn't match total hits

Hi,

I've started to use aggregations and it works very fast and cool. But it
seems to get the wrong doc_count as opposed to the total hits.

For example - here's a typical search I use (I got for it total hits - 111
and doc_count 1348) :
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"term": {
"service_id": "880"
}
},
{
"bool": {
"must": {
"term": {
"status_group": "paying"
}
}
}
}
]
}
}
}
},
"aggregations": {
"atts": {
"nested": {
"path": "string_attributes"
},
"aggregations": {
"filter_atts": {
"filter": {
"term": {
"string_attributes.key": "Sales Manager"
}
},
"aggregations": {
"values": {
"terms": {
"field": "string_attributes.value",
"size": 0,
"order": {
"_term": "asc"
}
},
"aggregations": {
"reversed": {
"reverse_nested": {},
"aggregations": {
"health": {
"terms": {
"field": "health"
}
},
"missing_health": {
"missing": {
"field": "health"
}
},
"avg_contract_value": {
"avg": {
"field": "contract_value"
}
},
"sum_contract_value": {
"sum": {
"field": "contract_value"
}
}
}
}
}
}
}
}
}
},
"avg_contract_value": {
"avg": {
"field": "contract_value"
}
},
"sum_contract_value": {
"sum": {
"field": "contract_value"
}
}
}
}

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKHuyJpNLN8Zw7cQjFjTvQTpfrPLDkrhzBmEyFXApWYti1r1tQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

It sounds like you are using nested documents. I guess it comes from here.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 sept. 2014 à 07:49, Ron Sher ron.sher@gmail.com a écrit :

Hi,

I've started to use aggregations and it works very fast and cool. But it seems to get the wrong doc_count as opposed to the total hits.

For example - here's a typical search I use (I got for it total hits - 111 and doc_count 1348) :
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"term": {
"service_id": "880"
}
},
{
"bool": {
"must": {
"term": {
"status_group": "paying"
}
}
}
}
]
}
}
}
},
"aggregations": {
"atts": {
"nested": {
"path": "string_attributes"
},
"aggregations": {
"filter_atts": {
"filter": {
"term": {
"string_attributes.key": "Sales Manager"
}
},
"aggregations": {
"values": {
"terms": {
"field": "string_attributes.value",
"size": 0,
"order": {
"_term": "asc"
}
},
"aggregations": {
"reversed": {
"reverse_nested": {},
"aggregations": {
"health": {
"terms": {
"field": "health"
}
},
"missing_health": {
"missing": {
"field": "health"
}
},
"avg_contract_value": {
"avg": {
"field": "contract_value"
}
},
"sum_contract_value": {
"sum": {
"field": "contract_value"
}
}
}
}
}
}
}
}
}
},
"avg_contract_value": {
"avg": {
"field": "contract_value"
}
},
"sum_contract_value": {
"sum": {
"field": "contract_value"
}
}
}
}

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKHuyJpNLN8Zw7cQjFjTvQTpfrPLDkrhzBmEyFXApWYti1r1tQ%40mail.gmail.com.
For more options, visit 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3A592117-5A62-4B5E-A1C3-E954C275E1FC%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

So the doc count is for the nested documents?
what if I want to get the doc count of the "parent" docs? I guess I can use
the total hits, right?

On Saturday, September 6, 2014 8:52:30 AM UTC+3, David Pilato wrote:

It sounds like you are using nested documents. I guess it comes from here.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 sept. 2014 à 07:49, Ron Sher <ron....@gmail.com <javascript:>> a
écrit :

Hi,

I've started to use aggregations and it works very fast and cool. But it
seems to get the wrong doc_count as opposed to the total hits.

For example - here's a typical search I use (I got for it total hits - 111
and doc_count 1348) :
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"term": {
"service_id": "880"
}
},
{
"bool": {
"must": {
"term": {
"status_group": "paying"
}
}
}
}
]
}
}
}
},
"aggregations": {
"atts": {
"nested": {
"path": "string_attributes"
},
"aggregations": {
"filter_atts": {
"filter": {
"term": {
"string_attributes.key": "Sales Manager"
}
},
"aggregations": {
"values": {
"terms": {
"field": "string_attributes.value",
"size": 0,
"order": {
"_term": "asc"
}
},
"aggregations": {
"reversed": {
"reverse_nested": {},
"aggregations": {
"health": {
"terms": {
"field": "health"
}
},
"missing_health": {
"missing": {
"field": "health"
}
},
"avg_contract_value": {
"avg": {
"field": "contract_value"
}
},
"sum_contract_value": {
"sum": {
"field": "contract_value"
}
}
}
}
}
}
}
}
}
},
"avg_contract_value": {
"avg": {
"field": "contract_value"
}
},
"sum_contract_value": {
"sum": {
"field": "contract_value"
}
}
}
}

--
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 <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAKHuyJpNLN8Zw7cQjFjTvQTpfrPLDkrhzBmEyFXApWYti1r1tQ%40mail.gmail.com
https://groups.google.com/d/msgid/elasticsearch/CAKHuyJpNLN8Zw7cQjFjTvQTpfrPLDkrhzBmEyFXApWYti1r1tQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/774c45ee-6ded-4577-ab8b-e517844b34d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.