我想在猫鼬做geoNear +文本搜索汇总查询:
landmarkSchema.aggregate(
[
{ "$geoNear": {
"near": {
"type": "Point",
"coordinates": [parseFloat(userCoord1), parseFloat(userCoord0)]
},
"distanceField": "distance",
"minDistance": 1,
"maxDistance": 5000,
"spherical": true,
"query": { "loc.type": "Point" }
} },
{ $match: { $text: { $search: sText } } },
{ $sort: { score: { $meta: "textScore" } } }
],
function(err,data) {
if (data){
res.send(data);
}
else {
console.log('no results');
res.send({err:'no results'});
}
});
但蒙戈没有返回任何结果。当我单独执行每个查询时,将返回正确的结果,即$geoNear
和$match : $text
。我是否错误地链接查询?
从MongoDB的IRC用户说:“只有一个索引可以用于汇聚” - 任何人有这种类型的查询的最佳实践? – alyx 2015-02-23 22:44:30