# Can't set doc\_values=true for Boolean field

**URL:** <https://discuss.elastic.co/t/cant-set-doc-values-true-for-boolean-field/31736>\
**Category:** Elasticsearch\
**Created:** [October 6, 2015, 9:58pm UTC](https://discuss.elastic.co/t/cant-set-doc-values-true-for-boolean-field/31736 "2015-10-06T21:58:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpowers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mpowers/32/4824_2.png) [@mpowers](https://discuss.elastic.co/u/mpowers)\
**Post date:** [October 6, 2015, 9:58pm UTC](https://discuss.elastic.co/t/cant-set-doc-values-true-for-boolean-field/31736/1 "2015-10-06T21:58:54Z")

</div>

I'm having some trouble getting doc\_values=true to work for a Boolean field. I can use mappings that set it, but when I read the mappings back out, doc\_values are not appearing on my field. I'm going to paste a bunch of my Marvel/Sense commands and output

Here's my software version:

```
GET /

   "status": 200,
   "name": "Water Wizard",
   "cluster_name": "elasticsearch_mpowers",
   "version": {
      "number": "1.6.0",
      "build_hash": "cdd3ac4dde4f69524ec0a14de3828cb95bbb86d0",
      "build_timestamp": "2015-06-09T13:36:34Z",
      "build_snapshot": false,
      "lucene_version": "4.10.4"
   },
   "tagline": "You Know, for Search"
}

```

So here's the mappings I send to Elasticsearch, stripped down to the essential field:

```
PUT /test-app/company_user/_mapping

    {
      "dynamic": "false",
      "properties": {
        "asdf1234": {
          "type": "boolean",
          "doc_values": true
        }
      }
    }

```

Here's the mappings that come back out:

```
GET /test-app/company_user/_mapping
{
   "test-app": {
      "mappings": {
         "company_user": {
            "dynamic": "false",
            "properties": {
               "asdf1234": {
                  "type": "boolean"
               }
            }
         }
      }
   }
}

```

doc\_values seems to work ok for integers, floats, and not\_analyzed strings, it's just giving me trouble with Boolean fields for some reason. It's really puzzling! Any ideas?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 7, 2015, 3:15am UTC](https://discuss.elastic.co/t/cant-set-doc-values-true-for-boolean-field/31736/2 "2015-10-07T03:15:37Z")

</div>

We store this as a binary T/F behind the scenes so there's no way to even analyse it, so I can see why you are getting that.

I'll ask and see what the underlying reason is.

---

<div class="post-metadata">

**Author:** ![ppf2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppf2/32/52219_2.png) [@ppf2](https://discuss.elastic.co/u/ppf2)\
**Post date:** [October 7, 2015, 6:31am UTC](https://discuss.elastic.co/t/cant-set-doc-values-true-for-boolean-field/31736/3 "2015-10-07T06:31:20Z")

</div>

This [will be possible](https://github.com/elastic/elasticsearch/pull/7961) in the upcoming ES 2.0 release.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 7, 2015, 7:33am UTC](https://discuss.elastic.co/t/cant-set-doc-values-true-for-boolean-field/31736/4 "2015-10-07T07:33:40Z")

</div>

Nice!

---

<div class="post-metadata">

**Author:** ![mpowers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mpowers/32/4824_2.png) [@mpowers](https://discuss.elastic.co/u/mpowers)\
**Post date:** [October 7, 2015, 6:00pm UTC](https://discuss.elastic.co/t/cant-set-doc-values-true-for-boolean-field/31736/5 "2015-10-07T18:00:17Z")

</div>

Thanks for the answer. Would like to point out that the reason for my confusion was that the documentation for doc\_values claims that booleans are handled just like other numeric types: [https://www.elastic.co/guide/en/elasticsearch/guide/current/doc-values.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/doc-values.html)

"Doc values can be enabled for numeric, date, Boolean, binary, and geo-point fields, and for not\_analyzed string fields."

Also, the server does not raise an error when you ask for a doc\_values boolean field, it just silently discards that attribute.

Thanks again!  
Marshall

---

<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 5, 2017, 11:46pm UTC](https://discuss.elastic.co/t/cant-set-doc-values-true-for-boolean-field/31736/6 "2017-07-05T23:46:06Z")

</div>


