# What does "docCount" mean in the Explain API?

**URL:** <https://discuss.elastic.co/t/what-does-doccount-mean-in-the-explain-api/136915>\
**Category:** Elasticsearch\
**Created:** [June 21, 2018, 4:11pm UTC](https://discuss.elastic.co/t/what-does-doccount-mean-in-the-explain-api/136915 "2018-06-21T16:11:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sang-gon\_Lee](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@Sang-gon\_Lee](https://discuss.elastic.co/u/Sang-gon_Lee)\
**Post date:** [June 21, 2018, 4:11pm UTC](https://discuss.elastic.co/t/what-does-doccount-mean-in-the-explain-api/136915/1 "2018-06-21T16:11:36Z")

</div>

This is a portion of the response that I got from sending an explain API:

```
"_explanation": {
	"value": 15.811229,
	"description": "sum of:",
	"details": [
		{
			"value": 1,
			"description": "ConstantScore(NormsFieldExistsQuery [field=body])",
			"details": []
		},
		{
			"value": 14.811229,
			"description": "weight(body:unli in 151924) [PerFieldSimilarity], result of:",
			"details": [
				{
					"value": 14.811229,
					"description": "score(doc=151924,freq=1.0 = termFreq=1.0\n), product of:",
					"details": [
						{
						        "value": 12.410724,
						        "description": "idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:",
								"details": [
									{
										"value": 1,
										"description": "docFreq",
										"details": []
									},
									{
										"value": 368128,
										"description": "docCount",
										"details": []
									}
								]
							},

```

The "docFreq" is explained in the documentation and that makes sense.  
I don't understand what "docCount" means though. At first I thought it might be the number of matching documents for this query, but the number of hits returned is 16, nowhere near 370k. Also, looking at the formula this docCount contributes positively to the score, but it doesn't seem to make sense the number of matches gives boost to the score of this single document.  
We're using v6.3.0.  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mayya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayya/32/83147_2.png) [@mayya](https://discuss.elastic.co/u/mayya)\
**Post date:** [June 29, 2018, 8:20pm UTC](https://discuss.elastic.co/t/what-does-doccount-mean-in-the-explain-api/136915/2 "2018-06-29T20:20:08Z")

</div>

The `docCount` here is the total number of documents in the index.  
A simplified version of the formula for `idf(term)` is `totalNumberOfDocs/(number of documents containing term)`.  
That is why it is called inverted document frequency. Rare terms that only few documents contain will have a higher value of `idf`, while popular terms that are contained in many documents, will have a lower value of `idf`.

---

<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 27, 2018, 8:20pm UTC](https://discuss.elastic.co/t/what-does-doccount-mean-in-the-explain-api/136915/3 "2018-07-27T20:20:09Z")

</div>

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