Begin compile function, to create a query mongo understands