Binh,
It's even more interesting. The behavior you describe matches the
configuration and REST parsing rules. But the document _source is JSON and
a boolean value must be either true or false. So my recommendation is
to use the configuration and REST interface as a forgiving practice to get
used to specifying only true or false for boolean parameters, and then
you'll be comfortably set when you start adding real data.
And it's one more reason to lock down Elasticsearch to prevent it from
automatically detecting field types, and then explicitly map all of the
fields you need.
For example, the pretty= HTTP REST parameter is a boolean. And here are the
results:
brian@liberator:~$ curl -XGET 'http://localhost:9200/_nodes/process?
pretty=false&human=true' && echo
{"cluster_name":"brian-liberator","nodes":{"wY-tmDrATweDeltdz9xCiQ":{"name":"liberator","transport_address":"inet[/192.168.1.70:9300]","host":"liberator","ip":"127.0.1.1","version":"1.0.0","build":"a46900e","http_address":"inet[/192.168.1.70:9200]","attributes":{"max_local_storage_nodes":"1"},"process":{"refresh_interval":1000,"id":2864,"max_file_descriptors":65537,"mlockall":false}}}}
brian@liberator:~$ curl -XGET 'http://localhost:9200/_nodes/process?
pretty=true&human=true' && echo
{
"cluster_name" : "brian-liberator",
"nodes" : {
"wY-tmDrATweDeltdz9xCiQ" : {
"name" : "liberator",
"transport_address" : "inet[/192.168.1.70:9300]",
"host" : "liberator",
"ip" : "127.0.1.1",
"version" : "1.0.0",
"build" : "a46900e",
"http_address" : "inet[/192.168.1.70:9200]",
"attributes" : {
"max_local_storage_nodes" : "1"
},
"process" : {
"refresh_interval" : 1000,
"id" : 2864,
"max_file_descriptors" : 65537,
"mlockall" : false
}
}
}
}
brian@liberator:~$ curl -XGET 'http://localhost:9200/_nodes/process?
pretty=AsPrettyDoes&human=true' && echo
{
"cluster_name" : "brian-liberator",
"nodes" : {
"wY-tmDrATweDeltdz9xCiQ" : {
"name" : "liberator",
"transport_address" : "inet[/192.168.1.70:9300]",
"host" : "liberator",
"ip" : "127.0.1.1",
"version" : "1.0.0",
"build" : "a46900e",
"http_address" : "inet[/192.168.1.70:9200]",
"attributes" : {
"max_local_storage_nodes" : "1"
},
"process" : {
"refresh_interval" : 1000,
"id" : 2864,
"max_file_descriptors" : 65537,
"mlockall" : false
}
}
}
}
But JSON is not so forgiving. Here is a JSON document, followed by the
output from a parser application I wrote last year:
brian@liberator:~$ cat /tmp/test.json
{
"v1" : true,
"v2" : false,
"v3" : 0,
"v4" : "0",
"v5" : 1,
"v6" : "1",
"v7" : TRUE
}
brian@liberator:~$ parse-json.sh /tmp/test.json
JSON PARSED VALUES:
((NAME null)(TEXT {') (TOKEN START_OBJECT)) ((NAME v1)(TEXT
true') (TOKEN VALUE_TRUE))
((NAME v2)(TEXT false') (TOKEN VALUE_FALSE)) ((NAME v3)(TEXT
0') (TOKEN VALUE_NUMBER_INT))
((NAME v4)(TEXT 0') (TOKEN VALUE_STRING)) ((NAME v5)(TEXT
1') (TOKEN VALUE_NUMBER_INT))
((NAME v6)(TEXT `1') (TOKEN VALUE_STRING))
*JSON parse failure:
org.elasticsearch.common.jackson.core.JsonParseException: Unrecognized
token 'TRUE': was expecting *
- at [Source: java.io.BufferedReader@1662dc8; line: 8, column: 14]*
Brian
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/357cbf17-fab4-428f-a88d-d50cdd49110f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.