# How boolean fields are indexed in ElasticSearch? Doc values on boolean?

**URL:** <https://discuss.elastic.co/t/how-boolean-fields-are-indexed-in-elasticsearch-doc-values-on-boolean/20049>\
**Category:** Elasticsearch\
**Created:** [October 2, 2014, 12:19pm UTC](https://discuss.elastic.co/t/how-boolean-fields-are-indexed-in-elasticsearch-doc-values-on-boolean/20049 "2014-10-02T12:19:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Han\_JU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/han_ju/32/962_2.png) [@Han\_JU](https://discuss.elastic.co/u/Han_JU)\
**Post date:** [October 2, 2014, 12:19pm UTC](https://discuss.elastic.co/t/how-boolean-fields-are-indexed-in-elasticsearch-doc-values-on-boolean/20049/1 "2014-10-02T12:19:01Z")

</div>

Hi,

I'm taking some time reviewing our mapping.  
We've put doc\_values for the fields that aggregation will be calculated.  
But I'm not sure is there any benefit to do this for boolean field?  
This also leads me to wonder how ElasticSearch (or Lucene) index boolean  
fields?

Some insights or readings? Thanks

Han

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fa01f952-e577-470e-a5d2-13e6fbd381b8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fa01f952-e577-470e-a5d2-13e6fbd381b8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [October 2, 2014, 9:39pm UTC](https://discuss.elastic.co/t/how-boolean-fields-are-indexed-in-elasticsearch-doc-values-on-boolean/20049/2 "2014-10-02T21:39:50Z")

</div>

Hi,

Boolean fields don't support doc values yet, although there is some work in  
progress: [Add doc values support to boolean fields. by jpountz · Pull Request #7961 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/7961)

Boolean fields are simply indexed as strings: "T" for true and "F" for  
false and field data would require about 2 bits per document (one to know  
if the document has a value, and one to store the value). That's not much  
but it can still use quite some memory if you have lots of memory. If/when  
doc values support comes to booleans, this will help move most of this  
memory usage to disk and the filesystem cache.

On Thu, Oct 2, 2014 at 2:19 PM, Han JU [ju.han.felix@gmail.com](mailto:ju.han.felix@gmail.com) wrote:

> Hi,
> 
> I'm taking some time reviewing our mapping.  
> We've put doc\_values for the fields that aggregation will be calculated.  
> But I'm not sure is there any benefit to do this for boolean field?  
> This also leads me to wonder how Elasticsearch (or Lucene) index boolean  
> fields?
> 
> Some insights or readings? Thanks
> 
> Han
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/fa01f952-e577-470e-a5d2-13e6fbd381b8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fa01f952-e577-470e-a5d2-13e6fbd381b8%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/fa01f952-e577-470e-a5d2-13e6fbd381b8%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/fa01f952-e577-470e-a5d2-13e6fbd381b8%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5cR\_nBYeUsXa\_bZDRs71Xmn1d\_s%2B%3DjOCYCQyaKc%2B-RLQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5cR_nBYeUsXa_bZDRs71Xmn1d_s%2B%3DjOCYCQyaKc%2B-RLQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:58am UTC](https://discuss.elastic.co/t/how-boolean-fields-are-indexed-in-elasticsearch-doc-values-on-boolean/20049/3 "2017-07-06T00:58:32Z")

</div>


