encode query when sending to auto_index