Implemented query encoding.