Make erlbison deduce datatype of query from the document

* please do no close yet, till arrays and documents are handled *