Query plugins

based on #806 
fix #693