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});
});
}
});
search()方法不知道从哪里来的,这个方法接受了三个参数:
1、
filtered: {
query: {query_string: {query:key}},
filter: filter
}
2、
{from: page * 40, size: 40}
3、
function (err, results) {
var items = results ? results.hits.hits : [];
var total = results ? results.hits.total : 0; res.json({items: items, total:total});
}
静态方法中没有此方法;
此为问题