在mongodb中两次使用$geoNear的问题

在mongodb中两次使用$geoNear的问题,mongodb,mongodb-query,aggregation-framework,geonear,Mongodb,Mongodb Query,Aggregation Framework,Geonear,我想通过应用以下过滤器对搜索公司进行mongodb查询 { myLocation: [lng1, lat1], // That is to get distance from current location to companies on result. region: [lng2, lat2], //That is to get companies within a radius in this region radius: 10000, tags: ["ta

我想通过应用以下过滤器对搜索公司进行mongodb查询

{
    myLocation: [lng1, lat1], // That is to get distance from current location to companies on result.
    region: [lng2, lat2], //That is to get companies within a radius in this region
    radius: 10000,
    tags: ["tag1", "tag2"],
    sort: "asc" // to sort by nearest from current location.
}
我认为它需要使用$geoNear两次,并进行了如下聚合

{
    $geoNear: {
        near: {
            type: "Point",
            coordinates: myLocation
        },
        distanceField: 'distance1',
        maxDistance: radius,
        spherical: true,
    },
    $match: { tags: tags },
    $geoNear: {
        near: {
            type: "Point",
            coordinates: region
        },
        distanceField: 'distance2',
        spherical: true,
    }
}
但出现了一个错误-$geoNear仅在管道的第一阶段有效

有没有办法进行查询以使用此筛选器

谢谢你的帮助