added search functions to database files, removed reds from nodebb moved it to redis

This commit is contained in:
Baris Soner Usakli
2013-12-05 20:06:36 -05:00
parent 6c70d37f1c
commit 53ca7a1143
9 changed files with 110 additions and 47 deletions

View File

@@ -226,18 +226,8 @@ var path = require('path'),
app.get('/search/:term', function (req, res, next) {
var reds = require('reds');
var postSearch = reds.createSearch('nodebbpostsearch');
var topicSearch = reds.createSearch('nodebbtopicsearch');
function search(searchObj, callback) {
searchObj
.query(query = req.params.term).type('or')
.end(callback);
}
function searchPosts(callback) {
search(postSearch, function (err, pids) {
db.search('post', req.params.term, function(err, pids) {
if (err) {
return callback(err, null);
}
@@ -248,11 +238,11 @@ var path = require('path'),
}
callback(null, posts);
});
})
});
}
function searchTopics(callback) {
search(topicSearch, function (err, tids) {
db.search('topic', req.params.term, function(err, tids) {
if (err) {
return callback(err, null);
}