Rewrite metadata/query model