1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

adding keyword and place to search and instant serach

This commit is contained in:
Braun Patrik 2016-05-15 21:25:59 +02:00
parent eb46c53bbb
commit 60dab77cf4

View File

@ -71,10 +71,14 @@ export class MongoSearchManager implements ISearchManager {
let result:SearchResult = new SearchResult(); let result:SearchResult = new SearchResult();
result.searchText = text; result.searchText = text;
PhotoModel.find({ PhotoModel.find({
name: { $or: [
$regex: text, {name: {$regex: text, $options: "i"}},
$options: "i" {"metadata.positionData.city": {$regex: text, $options: "i"}},
} {"metadata.positionData.state": {$regex: text, $options: "i"}},
{"metadata.positionData.country": {$regex: text, $options: "i"}},
{"metadata.keywords": {$regex: text, $options: "i"}}
]
}).populate('directory', 'name path').exec((err, res:Array<any>) => { }).populate('directory', 'name path').exec((err, res:Array<any>) => {
if (err || !res) { if (err || !res) {
return cb(err, null); return cb(err, null);
@ -103,10 +107,14 @@ export class MongoSearchManager implements ISearchManager {
let result:SearchResult = new SearchResult(); let result:SearchResult = new SearchResult();
result.searchText = text; result.searchText = text;
PhotoModel.find({ PhotoModel.find({
name: { $or: [
$regex: text, {name: {$regex: text, $options: "i"}},
$options: "i" {"metadata.positionData.city": {$regex: text, $options: "i"}},
} {"metadata.positionData.state": {$regex: text, $options: "i"}},
{"metadata.positionData.country": {$regex: text, $options: "i"}},
{"metadata.keywords": {$regex: text, $options: "i"}}
]
}).limit(10).populate('directory', 'name path').exec((err, res:Array<any>) => { }).limit(10).populate('directory', 'name path').exec((err, res:Array<any>) => {
if (err || !res) { if (err || !res) {
return cb(err, null); return cb(err, null);