Storing booleans as '0' and '1'

Hi, I want to store booleans as '1's and '0's. Is this possible? I've tried storing them as strings but elasticsearch infered they were boolean value.

Thanks

Hi,

What exactly do you mean by "store" them? If you don't provide a Mapping elasticsearch will try to infer the field type of fields it doesn't know yet. Values like 0/1/true/false are treated as "boolean" if not explicitely specified. Regardless, if you index new documents with that said field, the "_source" of that document will always reflect the original JSON you used at index time, so if you have indexed a boolean field as "foo" : 1, "foo": "1" or "foo": true, this will always reflect in the docs "_source". Under the hood, booleans are stored as 1-char bytes in Lucene, so nothing to do there.

Or do you want to store them as Strings for some other reason?