# Strange problem with a boolean field

**URL:** <https://discuss.elastic.co/t/strange-problem-with-a-boolean-field/10026>\
**Category:** Elasticsearch\
**Created:** [December 11, 2012, 1:35am UTC](https://discuss.elastic.co/t/strange-problem-with-a-boolean-field/10026 "2012-12-11T01:35:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_Clark1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_clark1/32/2581_2.png) [@Ian\_Clark1](https://discuss.elastic.co/u/Ian_Clark1)\
**Post date:** [December 11, 2012, 1:35am UTC](https://discuss.elastic.co/t/strange-problem-with-a-boolean-field/10026/1 "2012-12-11T01:35:23Z")

</div>

Hi,

has anyone had a problem with a boolean field having a value 't' when  
normally it is 'T' or 'F' (for true and false)? It's happens to me  
occasionally in my integration tests. I've tried to simplify the problem  
into a gist, but annoyingly it doesn't happen when I do that... grr.

A screenshot of the problem:-

[https://docs.google.com/open?id=0B3kE2Ho2wIf5ZjltNjJKNEJ2cG8](https://docs.google.com/open?id=0B3kE2Ho2wIf5ZjltNjJKNEJ2cG8)

here's roughly what happens as a gist:-

> <https://gist.github.com/ianAndrewClark/98a3287dea857ec12ec9>

(but that actually works for me)

Any ideas?

--

---

<div class="post-metadata">

**Author:** ![Kay\_Ropke](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kay_ropke/32/2424_2.png) [@Kay\_Ropke](https://discuss.elastic.co/u/Kay_Ropke)\
**Post date:** [December 11, 2012, 10:15am UTC](https://discuss.elastic.co/t/strange-problem-with-a-boolean-field/10026/2 "2012-12-11T10:15:13Z")

</div>

Hi!

On 11.12.2012, at 02:35, Ian Clark wrote:

> has anyone had a problem with a boolean field having a value 't' when normally it is 'T' or 'F' (for true and false)? It's happens to me occasionally in my integration tests. I've tried to simplify the problem into a gist, but annoyingly it doesn't happen when I do that... grr.

You've come across this: [Facet value of boolean mapped fields should be "true" or "false" · Issue #2462 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2462)  
Boolean values are stored as 'T' and 'F' in the index, but aren't properly converted back to 'true' and 'false' when being returned to a client.  
There's a workaround and a patch, but I guess it will take a little while to get it in a release.

cheers,  
-k

--

---

<div class="post-metadata">

**Author:** ![Ian\_Clark1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_clark1/32/2581_2.png) [@Ian\_Clark1](https://discuss.elastic.co/u/Ian_Clark1)\
**Post date:** [December 11, 2012, 11:55am UTC](https://discuss.elastic.co/t/strange-problem-with-a-boolean-field/10026/3 "2012-12-11T11:55:54Z")

</div>

Where does my little 't' value come from? It is a problem for me in that:-  
I then filter on true, and get back all results minus the little 't'  
document:-

like so:- [failing-filter.json · GitHub](https://gist.github.com/26a7f43bcbbfbff836a6)

IC

On Tue, Dec 11, 2012 at 10:15 AM, Kay Röpke [kroepke@gmail.com](mailto:kroepke@gmail.com) wrote:

> Hi!
> 
> On 11.12.2012, at 02:35, Ian Clark wrote:
> 
> has anyone had a problem with a boolean field having a value 't' when  
> normally it is 'T' or 'F' (for true and false)? It's happens to me  
> occasionally in my integration tests. I've tried to simplify the problem  
> into a gist, but annoyingly it doesn't happen when I do that... grr.
> 
> You've come across this:  
> [Facet value of boolean mapped fields should be "true" or "false" · Issue #2462 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2462)  
> Boolean values are stored as 'T' and 'F' in the index, but aren't properly  
> converted back to 'true' and 'false' when being returned to a client.  
> There's a workaround and a patch, but I guess it will take a little while  
> to get it in a release.
> 
> cheers,  
> -k
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [December 13, 2012, 9:32pm UTC](https://discuss.elastic.co/t/strange-problem-with-a-boolean-field/10026/4 "2012-12-13T21:32:08Z")

</div>

I tried it with 0.20.1 and I cannot reproduce it. Which version of es and  
java are you using? Is it reproducible on a fresh install of elasticsearch?  
All I am getting is

"facets" : {  
"verified\_terms" : {  
"\_type" : "terms",  
"missing" : 0,  
"total" : 30,  
"other" : 0,  
"terms" : [ {  
"term" : "T",  
"count" : 30  
} ]  
}  
}

On Tuesday, December 11, 2012 6:55:54 AM UTC-5, Ian Clark wrote:

> Where does my little 't' value come from? It is a problem for me in that:-  
> I then filter on true, and get back all results minus the little 't'  
> document:-
> 
> like so:- [failing-filter.json · GitHub](https://gist.github.com/26a7f43bcbbfbff836a6)
> 
> IC
> 
> On Tue, Dec 11, 2012 at 10:15 AM, Kay Röpke \<[kro...@gmail.com](mailto:kro...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi!
> > 
> > On 11.12.2012, at 02:35, Ian Clark wrote:
> > 
> > has anyone had a problem with a boolean field having a value 't' when  
> > normally it is 'T' or 'F' (for true and false)? It's happens to me  
> > occasionally in my integration tests. I've tried to simplify the problem  
> > into a gist, but annoyingly it doesn't happen when I do that... grr.
> > 
> > You've come across this:  
> > [Facet value of boolean mapped fields should be "true" or "false" · Issue #2462 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2462)  
> > Boolean values are stored as 'T' and 'F' in the index, but aren't  
> > properly converted back to 'true' and 'false' when being returned to a  
> > client.  
> > There's a workaround and a patch, but I guess it will take a little while  
> > to get it in a release.
> > 
> > cheers,  
> > -k
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![Ian\_Clark1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_clark1/32/2581_2.png) [@Ian\_Clark1](https://discuss.elastic.co/u/Ian_Clark1)\
**Post date:** [December 14, 2012, 12:10pm UTC](https://discuss.elastic.co/t/strange-problem-with-a-boolean-field/10026/5 "2012-12-14T12:10:21Z")

</div>

Hi,

I was using a snapshot when I ran it manually and 0.20.1 in my integration  
test, having sorted that out I can now reproduce the problem with this  
simpler script:-

> <https://gist.github.com/ianAndrewClark/4284891>

My java version is 1.7u9. Do this fail for you?

thanks for looking.

On Thu, Dec 13, 2012 at 9:32 PM, Igor Motov [imotov@gmail.com](mailto:imotov@gmail.com) wrote:

> I tried it with 0.20.1 and I cannot reproduce it. Which version of es and  
> java are you using? Is it reproducible on a fresh install of elasticsearch?  
> All I am getting is
> 
> "facets" : {  
> "verified\_terms" : {  
> "\_type" : "terms",  
> "missing" : 0,  
> "total" : 30,  
> "other" : 0,  
> "terms" : [ {  
> "term" : "T",  
> "count" : 30  
> } ]  
> }  
> }
> 
> On Tuesday, December 11, 2012 6:55:54 AM UTC-5, Ian Clark wrote:
> 
> > Where does my little 't' value come from? It is a problem for me in  
> > that:- I then filter on true, and get back all results minus the little 't'  
> > document:-
> > 
> > like so:- [https://gist.github.com/\*\*26a7f43bcbbfbff836a6](https://gist.github.com/**26a7f43bcbbfbff836a6)[https://gist.github.com/26a7f43bcbbfbff836a6](https://gist.github.com/26a7f43bcbbfbff836a6)
> > 
> > IC
> > 
> > On Tue, Dec 11, 2012 at 10:15 AM, Kay Röpke [kro...@gmail.com](mailto:kro...@gmail.com) wrote:
> > 
> > > Hi!
> > > 
> > > On 11.12.2012, at 02:35, Ian Clark wrote:
> > > 
> > > has anyone had a problem with a boolean field having a value 't' when  
> > > normally it is 'T' or 'F' (for true and false)? It's happens to me  
> > > occasionally in my integration tests. I've tried to simplify the problem  
> > > into a gist, but annoyingly it doesn't happen when I do that... grr.
> > > 
> > > You've come across this: [https://github.com/](https://github.com/)\*\*  
> > > elasticsearch/elasticsearch/\*\*issues/2462[https://github.com/elasticsearch/elasticsearch/issues/2462](https://github.com/elasticsearch/elasticsearch/issues/2462)  
> > > Boolean values are stored as 'T' and 'F' in the index, but aren't  
> > > properly converted back to 'true' and 'false' when being returned to a  
> > > client.  
> > > There's a workaround and a patch, but I guess it will take a little  
> > > while to get it in a release.
> > > 
> > > cheers,  
> > > -k
> > > 
> > > --
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [December 14, 2012, 5:26pm UTC](https://discuss.elastic.co/t/strange-problem-with-a-boolean-field/10026/6 "2012-12-14T17:26:13Z")

</div>

Ian,

Thank you for reporting the bug. We are looking into it. As a work around,  
you can fix your mapping by moving the "mappings" element to the same level  
as "settings":

curl -XPUT '[http://localhost:9200/booltest/](http://localhost:9200/booltest/)' -d '  
{  
"settings": {  
"index": {  
"number\_of\_shards": 1,  
"number\_of\_replicas": 0  
}  
},  
"mappings": {  
"thing": {  
"properties": {  
"flag": { "type" : "boolean" }  
},  
"\_all": {  
"enabled": "false"  
}  
}  
}  
}  
'

Igor

On Friday, December 14, 2012 4:10:21 AM UTC-8, Ian Clark wrote:

> Hi,
> 
> I was using a snapshot when I ran it manually and 0.20.1 in my integration  
> test, having sorted that out I can now reproduce the problem with this  
> simpler script:-
> 
> [problem with boolean fields · GitHub](https://gist.github.com/4284891)
> 
> My java version is 1.7u9. Do this fail for you?
> 
> thanks for looking.
> 
> On Thu, Dec 13, 2012 at 9:32 PM, Igor Motov \<[imo...@gmail.com](mailto:imo...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > I tried it with 0.20.1 and I cannot reproduce it. Which version of es and  
> > java are you using? Is it reproducible on a fresh install of elasticsearch?  
> > All I am getting is
> > 
> > "facets" : {  
> > "verified\_terms" : {  
> > "\_type" : "terms",  
> > "missing" : 0,  
> > "total" : 30,  
> > "other" : 0,  
> > "terms" : [ {  
> > "term" : "T",  
> > "count" : 30  
> > } ]  
> > }  
> > }
> > 
> > On Tuesday, December 11, 2012 6:55:54 AM UTC-5, Ian Clark wrote:
> > 
> > > Where does my little 't' value come from? It is a problem for me in  
> > > that:- I then filter on true, and get back all results minus the little 't'  
> > > document:-
> > > 
> > > like so:- [https://gist.github.com/\*\*26a7f43bcbbfbff836a6](https://gist.github.com/**26a7f43bcbbfbff836a6)[https://gist.github.com/26a7f43bcbbfbff836a6](https://gist.github.com/26a7f43bcbbfbff836a6)
> > > 
> > > IC
> > > 
> > > On Tue, Dec 11, 2012 at 10:15 AM, Kay Röpke [kro...@gmail.com](mailto:kro...@gmail.com) wrote:
> > > 
> > > > Hi!
> > > > 
> > > > On 11.12.2012, at 02:35, Ian Clark wrote:
> > > > 
> > > > has anyone had a problem with a boolean field having a value 't' when  
> > > > normally it is 'T' or 'F' (for true and false)? It's happens to me  
> > > > occasionally in my integration tests. I've tried to simplify the problem  
> > > > into a gist, but annoyingly it doesn't happen when I do that... grr.
> > > > 
> > > > You've come across this: [https://github.com/](https://github.com/)\*\*  
> > > > elasticsearch/elasticsearch/\*\*issues/2462[https://github.com/elasticsearch/elasticsearch/issues/2462](https://github.com/elasticsearch/elasticsearch/issues/2462)  
> > > > Boolean values are stored as 'T' and 'F' in the index, but aren't  
> > > > properly converted back to 'true' and 'false' when being returned to a  
> > > > client.  
> > > > There's a workaround and a patch, but I guess it will take a little  
> > > > while to get it in a release.
> > > > 
> > > > cheers,  
> > > > -k
> > > > 
> > > > --
> > > 
> > > --

--

---

<div class="post-metadata">

**Author:** ![Ian\_Clark1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ian_clark1/32/2581_2.png) [@Ian\_Clark1](https://discuss.elastic.co/u/Ian_Clark1)\
**Post date:** [December 14, 2012, 5:55pm UTC](https://discuss.elastic.co/t/strange-problem-with-a-boolean-field/10026/7 "2012-12-14T17:55:56Z")

</div>

Igor,

I totally missed that, so it was falling back to a dynamic mapping and that  
is the problem?

Thanks for looking and the work around.

Ian

On Fri, Dec 14, 2012 at 5:26 PM, Igor Motov [imotov@gmail.com](mailto:imotov@gmail.com) wrote:

> Ian,
> 
> Thank you for reporting the bug. We are looking into it. As a work around,  
> you can fix your mapping by moving the "mappings" element to the same level  
> as "settings":
> 
> curl -XPUT '[http://localhost:9200/booltest/](http://localhost:9200/booltest/)' -d '  
> {  
> "settings": {  
> "index": {  
> "number\_of\_shards": 1,  
> "number\_of\_replicas": 0  
> }  
> },  
> "mappings": {  
> "thing": {  
> "properties": {  
> "flag": { "type" : "boolean" }  
> },  
> "\_all": {  
> "enabled": "false"  
> }  
> }  
> }  
> }  
> '
> 
> Igor
> 
> On Friday, December 14, 2012 4:10:21 AM UTC-8, Ian Clark wrote:
> 
> > Hi,
> > 
> > I was using a snapshot when I ran it manually and 0.20.1 in my  
> > integration test, having sorted that out I can now reproduce the problem  
> > with this simpler script:-
> > 
> > [https://gist.github.com/\*\*4284891](https://gist.github.com/**4284891) [https://gist.github.com/4284891](https://gist.github.com/4284891)
> > 
> > My java version is 1.7u9. Do this fail for you?
> > 
> > thanks for looking.
> > 
> > On Thu, Dec 13, 2012 at 9:32 PM, Igor Motov [imo...@gmail.com](mailto:imo...@gmail.com) wrote:
> > 
> > > I tried it with 0.20.1 and I cannot reproduce it. Which version of es  
> > > and java are you using? Is it reproducible on a fresh install of  
> > > elasticsearch? All I am getting is
> > > 
> > > "facets" : {  
> > > "verified\_terms" : {  
> > > "\_type" : "terms",  
> > > "missing" : 0,  
> > > "total" : 30,  
> > > "other" : 0,  
> > > "terms" : [ {  
> > > "term" : "T",  
> > > "count" : 30  
> > > } ]  
> > > }  
> > > }
> > > 
> > > On Tuesday, December 11, 2012 6:55:54 AM UTC-5, Ian Clark wrote:
> > > 
> > > > Where does my little 't' value come from? It is a problem for me in  
> > > > that:- I then filter on true, and get back all results minus the little 't'  
> > > > document:-
> > > > 
> > > > like so:- [https://gist.github.com/\*\*2\*\*6a7f43bcbbfbff836a6](https://gist.github.com/ **2** 6a7f43bcbbfbff836a6)[https://gist.github.com/26a7f43bcbbfbff836a6](https://gist.github.com/26a7f43bcbbfbff836a6)
> > > > 
> > > > IC
> > > > 
> > > > On Tue, Dec 11, 2012 at 10:15 AM, Kay Röpke [kro...@gmail.com](mailto:kro...@gmail.com) wrote:
> > > > 
> > > > > Hi!
> > > > > 
> > > > > On 11.12.2012, at 02:35, Ian Clark wrote:
> > > > > 
> > > > > has anyone had a problem with a boolean field having a value 't' when  
> > > > > normally it is 'T' or 'F' (for true and false)? It's happens to me  
> > > > > occasionally in my integration tests. I've tried to simplify the problem  
> > > > > into a gist, but annoyingly it doesn't happen when I do that... grr.
> > > > > 
> > > > > You've come across this: [https://github.com/\*\*elast](https://github.com/**elast)\*\*  
> > > > > icsearch/elasticsearch/\*\*issues/\*\*2462[https://github.com/elasticsearch/elasticsearch/issues/2462](https://github.com/elasticsearch/elasticsearch/issues/2462)  
> > > > > Boolean values are stored as 'T' and 'F' in the index, but aren't  
> > > > > properly converted back to 'true' and 'false' when being returned to a  
> > > > > client.  
> > > > > There's a workaround and a patch, but I guess it will take a little  
> > > > > while to get it in a release.
> > > > > 
> > > > > cheers,  
> > > > > -k
> > > > > 
> > > > > --
> > > > 
> > > > --
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [December 14, 2012, 5:58pm UTC](https://discuss.elastic.co/t/strange-problem-with-a-boolean-field/10026/8 "2012-12-14T17:58:15Z")

</div>

Yes, in your example it's effectively using dynamic mapping.

On Friday, December 14, 2012 9:55:56 AM UTC-8, Ian Clark wrote:

> Igor,
> 
> I totally missed that, so it was falling back to a dynamic mapping and  
> that is the problem?
> 
> Thanks for looking and the work around.
> 
> Ian
> 
> On Fri, Dec 14, 2012 at 5:26 PM, Igor Motov \<[imo...@gmail.com](mailto:imo...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Ian,
> > 
> > Thank you for reporting the bug. We are looking into it. As a work  
> > around, you can fix your mapping by moving the "mappings" element to the  
> > same level as "settings":
> > 
> > curl -XPUT '[http://localhost:9200/booltest/](http://localhost:9200/booltest/)' -d '  
> > {  
> > "settings": {  
> > "index": {  
> > "number\_of\_shards": 1,  
> > "number\_of\_replicas": 0  
> > }  
> > },  
> > "mappings": {  
> > "thing": {  
> > "properties": {  
> > "flag": { "type" : "boolean" }  
> > },  
> > "\_all": {  
> > "enabled": "false"  
> > }  
> > }  
> > }  
> > }  
> > '
> > 
> > Igor
> > 
> > On Friday, December 14, 2012 4:10:21 AM UTC-8, Ian Clark wrote:
> > 
> > > Hi,
> > > 
> > > I was using a snapshot when I ran it manually and 0.20.1 in my  
> > > integration test, having sorted that out I can now reproduce the problem  
> > > with this simpler script:-
> > > 
> > > [https://gist.github.com/\*\*4284891](https://gist.github.com/**4284891) [https://gist.github.com/4284891](https://gist.github.com/4284891)
> > > 
> > > My java version is 1.7u9. Do this fail for you?
> > > 
> > > thanks for looking.
> > > 
> > > On Thu, Dec 13, 2012 at 9:32 PM, Igor Motov [imo...@gmail.com](mailto:imo...@gmail.com) wrote:
> > > 
> > > > I tried it with 0.20.1 and I cannot reproduce it. Which version of es  
> > > > and java are you using? Is it reproducible on a fresh install of  
> > > > elasticsearch? All I am getting is
> > > > 
> > > > "facets" : {  
> > > > "verified\_terms" : {  
> > > > "\_type" : "terms",  
> > > > "missing" : 0,  
> > > > "total" : 30,  
> > > > "other" : 0,  
> > > > "terms" : [ {  
> > > > "term" : "T",  
> > > > "count" : 30  
> > > > } ]  
> > > > }  
> > > > }
> > > > 
> > > > On Tuesday, December 11, 2012 6:55:54 AM UTC-5, Ian Clark wrote:
> > > > 
> > > > > Where does my little 't' value come from? It is a problem for me in  
> > > > > that:- I then filter on true, and get back all results minus the little 't'  
> > > > > document:-
> > > > > 
> > > > > like so:- [https://gist.github.com/\*\*2\*\*6a7f43bcbbfbff836a6](https://gist.github.com/ **2** 6a7f43bcbbfbff836a6)[https://gist.github.com/26a7f43bcbbfbff836a6](https://gist.github.com/26a7f43bcbbfbff836a6)
> > > > > 
> > > > > IC
> > > > > 
> > > > > On Tue, Dec 11, 2012 at 10:15 AM, Kay Röpke [kro...@gmail.com](mailto:kro...@gmail.com) wrote:
> > > > > 
> > > > > > Hi!
> > > > > > 
> > > > > > On 11.12.2012, at 02:35, Ian Clark wrote:
> > > > > > 
> > > > > > has anyone had a problem with a boolean field having a value 't' when  
> > > > > > normally it is 'T' or 'F' (for true and false)? It's happens to me  
> > > > > > occasionally in my integration tests. I've tried to simplify the problem  
> > > > > > into a gist, but annoyingly it doesn't happen when I do that... grr.
> > > > > > 
> > > > > > You've come across this: [https://github.com/\*\*elast](https://github.com/**elast)\*\*  
> > > > > > icsearch/elasticsearch/\*\*issues/\*\*2462[https://github.com/elasticsearch/elasticsearch/issues/2462](https://github.com/elasticsearch/elasticsearch/issues/2462)  
> > > > > > Boolean values are stored as 'T' and 'F' in the index, but aren't  
> > > > > > properly converted back to 'true' and 'false' when being returned to a  
> > > > > > client.  
> > > > > > There's a workaround and a patch, but I guess it will take a little  
> > > > > > while to get it in a release.
> > > > > > 
> > > > > > cheers,  
> > > > > > -k
> > > > > > 
> > > > > > --
> > > > > 
> > > > > --
> > > 
> > > --

--

---

<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, 2:59am UTC](https://discuss.elastic.co/t/strange-problem-with-a-boolean-field/10026/9 "2017-07-06T02:59:49Z")

</div>


