LENS-24. Added fix to take rewritten query instead of user query