Text this: The efficient evaluation of visual queries within a logic-based framework