router.post('/search', function(req, res, next) { //Im confused right now. }); router.get('/search?q=search_term', function(req, res, next) { Product.search( { query_string: { query: req.query.q } } , function(err, results) { if (err) return next(err); var data = results.hits.hits.map(function(hit) { return hit; }); return res.render('main/search-results', { data: data }); }); });