encode query when sending to auto_index

Encode query when sending to auto_index