# SignificantTerms Agg : \_superset\_size greater than doc\_count !?

**URL:** <https://discuss.elastic.co/t/significantterms-agg--superset-size-greater-than-doc-count/29486>\
**Category:** Elasticsearch\
**Created:** [September 17, 2015, 2:54pm UTC](https://discuss.elastic.co/t/significantterms-agg--superset-size-greater-than-doc-count/29486 "2015-09-17T14:54:38Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![tomlameche](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomlameche/32/4832_2.png) [@tomlameche](https://discuss.elastic.co/u/tomlameche)\
**Post date:** [September 17, 2015, 5:28pm UTC](https://discuss.elastic.co/t/significantterms-agg--superset-size-greater-than-doc-count/29486/3 "2015-09-17T17:28:05Z")

</div>

yes, the definition of subset and superset is clear.  
My problem is that the value of \_superset\_size in a script is greater than the total number of document in my index. I think there is a bug somewhere.

I do a nested significant terms aggregation after a simple term aggregation, similar as the exemple describe here : [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html)

I need to perform a custom score and so i try to used "script\_heuristic" : the result seems strange for me, so i modify my script to view the value of each variable (\_superset\_size, \_superset\_freq, \_subset\_freq and \_subsetset\_size) with :  
"script\_heuristic": {  
"script": "\_superset\_size"  
}

And what a surprise : the value of \_superset\_size is greater than the number of total document in my index...

In addition, the value of bg\_count is greater than the value of total count for each terms, as descibe here [Bg\_counts in nested significant\_terms aggregation](https://discuss.elastic.co/t/bg-counts-in-nested-significant-terms-aggregation/21878/2)

There is a bug, i guess

---

_[View the full topic](https://discuss.elastic.co/t/significantterms-agg--superset-size-greater-than-doc-count/29486)._
