Pattern match queries in query_worker using FSM