Add query to output besides NS. Fix when query key is not in operation dict

Add query to output besides NS.
Fix when query key is not in operation dict