# Does IDF count documents that don't have a field

**URL:** <https://discuss.elastic.co/t/does-idf-count-documents-that-dont-have-a-field/245562>\
**Category:** Elasticsearch\
**Created:** [August 19, 2020, 9:10am UTC](https://discuss.elastic.co/t/does-idf-count-documents-that-dont-have-a-field/245562 "2020-08-19T09:10:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivanibash](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivanibash/32/60905_2.png) [@ivanibash](https://discuss.elastic.co/u/ivanibash)\
**Post date:** [August 19, 2020, 9:10am UTC](https://discuss.elastic.co/t/does-idf-count-documents-that-dont-have-a-field/245562/1 "2020-08-19T09:10:11Z")

</div>

First let me check my assumption is correct . As i understand ES calculates IDF across specific fields. So when I read things like "It is a ratio of all documents to documents containing the searched term." it really means "It is a ratio of all documents to documents containing the searched term _in the specific field you are searching_. So if I search a field "name", with a query "Robert", it's irrelevant if a document contains "Robert" in any other field. Correct?

Now, if there are two documents with a field "name", and one of them has "Robert" in it and the other doesn't, then IDF is log (2/1). However, what if the second document doesn't have a field name at all? Is it still counted? Is it log(1/1) in this case or still log(2/1)? Thanks

---

<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:** [September 16, 2020, 9:10am UTC](https://discuss.elastic.co/t/does-idf-count-documents-that-dont-have-a-field/245562/2 "2020-09-16T09:10:29Z")

</div>

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