Node.js Elasticsearch Mongoosastic From和Size分页

我正在使用Mongoosastic将我的模型索引到Elasticsearch,它的工作非常好,只有问题我有它的From和Size for分页。

根据Mongoosastic API

全查询Elasticsearch的DSL是通过search的方式公开的

基于Elasticsearch Api 从/大小我来这个代码

music.search( {query_string:{ query:term }},{"from" : 0},{"size" : 10}, { hydrate:true }, function(err,results) { console.log(results.hits.hits); }) 

之后runnig我想出了这个错误:

 /home/app/node_modules/mongoosastic/lib/mongoosastic.js:256 cb(null, res); ^ TypeError: object is not a function at /home/app/node_modules/mongoosastic/lib/mongoosastic.js:256:9 at respond (/home/app/node_modules/mongoosastic/node_modules/elasticsearch/src/lib/transport.js:256:9) at checkRespForFailure (/home/app/node_modules/mongoosastic/node_modules/elasticsearch/src/lib/transport.js:203:7) at HttpConnector.<anonymous> (/home/app/node_modules/mongoosastic/node_modules/elasticsearch/src/lib/connectors/http.js:156:7) at IncomingMessage.wrapper (/home/app/node_modules/lodash/index.js:3057:19) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:944:16 at process._tickCallback (node.js:448:13) 

有什么想法吗? 提前致谢!

Mongoosastic具有以下searchfunction的签名:

 schema.statics.search = function(query, options, cb) { // blah blah } 

它有三个参数,其次是选项。 因此,你的代码应该是这样的:

 music.search( { query_string: { query: term } }, { from: 0, size: 10, hydrate: true }, function(err,results) { console.log(results.hits.hits); } );