moving elasticsearch query generation to the client side