求救,读自己正在参与的项目,search()方法不知道出自哪里,有没有人能看出,是不是用了什么库,
router.get(’/api/tags/search/:list/:key/:page’, function(req, res) { if(_.isEmpty(req.params.key)) { res.json({items:null}); } else { var key = urlencode.decode(req.params.key);
var page = parseInt(req.params.page);
if(!page) page = 0;
var filter = {};
if(req.params.list != 'all')
filter = {term: {list: req.params.list}};
Tag.**search**({
filtered: {
query: {query_string: {query:key}},
filter: filter
}
}, {from: page * 40, size: 40}, function (err, results) {
var items = results ? results.hits.hits : [];
var total = results ? results.hits.total : 0;
res.json({items: items, total:total});
});
}
});