Can't set doc_values=true for Boolean field


(Marshall Powers) #1

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?


(Mark Walkom) #2

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.


#3

This will be possible in the upcoming ES 2.0 release.


(Mark Walkom) #4

Nice!


(Marshall Powers) #5

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

"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


(system) #6