Created
July 2, 2014 02:45
-
-
Save motiooon/ffb7e92d853e7d426110 to your computer and use it in GitHub Desktop.
Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'), | |
request = require('request'), | |
async = require('async'), | |
config = require('../config/config'), | |
_ = require('lodash'); | |
var helpers = require('../loopback_helpers'); | |
/** | |
* Do Search | |
*/ | |
exports.doSearch= function (req, res, next) { | |
var req_uri = config.mediaService.host + 'medias?filter[where][status]=published' + | |
// helpers.lbKeywords(req.query.q.split(' '))+ // !!!This one throws an error on the loopback service | |
helpers.lbObjKeywords(req.query.q.split(' '))+ // !Thiso ne is returnning 0 results | |
helpers.lbPick(['id', 'publishedOn', 'externalUUID', 'keywords']) + | |
'&filter[order]=publishedOn%20DESC' + helpers.lbGetPage(1); | |
console.log('about to request:', req_uri); | |
request({ | |
uri: req_uri, | |
method: 'GET' | |
},function (error, response, body) { | |
if (!error && response.statusCode === 200) { | |
var _medias = JSON.parse(body); | |
res.send(_medias); | |
}else{ | |
res.send(500); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment