For better documentation I send you my complete POST Request Handler
router.post('/search', function (req, res) {
try {
db.documents.query(
qb.where(
qb.parsedFrom(req.body.SearchString)
).slice(qb.snippet())
//.withOptions({categories: ['content', 'metadata']})
//.withOptions({categories: ['content']})
)
.result(function (documents) {
documents.forEach(function (document) {
console.log(document.content.name + " at " + document.uri);
})
res.render('index', { title: 'MVSearch', results : documents });
res.end();
}, function (error) {
console.dir(error);
res.render('index', { title: 'MVSearch', error : error });
res.end();
});
}
catch (e) {
res.render('index', { title: 'MVSearch', session : req.session, exp
: e });
console.log(e);
}
});
As soon as I use the slice I got the already mentioned error
Best Regards
Martin
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Martin
Vollmix
Gesendet: Sonntag, 7. Juni 2015 17:24
An: 'MarkLogic Developer Discussion'
Betreff: [MarkLogic Dev General] snippet do not work in querybuilder node.js
Hi,
the next problem I have is that snippet does not work in my node.js app
my query looks like this:
db.documents.query(
qb.where(qb.parsedFrom(req.body.SearchString))
.slice(qb.snippet())
//.withOptions({categories: ['content', 'metadata']})
//.withOptions({categories: ['content']})
)
The error I get is this one:
E:\Git\ExpressTest\node_modules\marklogic\node_modules\bluebird\js\main\asyn
c.js
:43
fn = function () { throw arg; };
^
TypeError: Cannot read property 'name' of undefined
at E:\Git\ExpressTest\routes\index.js:40:41
at Array.forEach (native)
at E:\Git\ExpressTest\routes\index.js:39:19
at tryCatcher
(E:\Git\ExpressTest\node_modules\marklogic\node_modules\bluebi
rd\js\main\util.js:24:31)
at Promise.module.exports.Promise._settlePromiseFromHandler
(E:\Git\ExpressT
est\node_modules\marklogic\node_modules\bluebird\js\main\promise.js:454:31)
at Promise.module.exports.Promise._settlePromiseAt
(E:\Git\ExpressTest\node_
modules\marklogic\node_modules\bluebird\js\main\promise.js:530:18)
at Promise.module.exports.Promise._settlePromises
(E:\Git\ExpressTest\node_m
odules\marklogic\node_modules\bluebird\js\main\promise.js:646:14)
at Async._drainQueue
(E:\Git\ExpressTest\node_modules\marklogic\node_modules
\bluebird\js\main\async.js:177:16)
at Async._drainQueues
(E:\Git\ExpressTest\node_modules\marklogic\node_module
s\bluebird\js\main\async.js:187:10)
at Immediate.drainQueues [as _onImmediate]
(E:\Git\ExpressTest\node_modules\
marklogic\node_modules\bluebird\js\main\async.js:15:14)
at processImmediate [as _immediateCallback] (timers.js:358:17)
What am I doing wrong?
Any hints
Best Regards
Martin
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general