Zaprto

Fix a mongoDB $geoNear aggregation query

I have a query that uses aggregation pipeline to retrieve all the records within a 200 mile radius. However, the query only returns 100 out of 156 records. I need this issue resolved.

pRadius = ((pRadius * [url removed, login to view]) / 180)*3963.2*69;

return new Promise(function(fullfill, reject){

[url removed, login to view](

[

{

$geoNear: {

near: { type: "Point", coordinates: [parseFloat(pLatLngArray[0]), parseFloat(pLatLngArray[1])] },

distanceField: "dist",

spherical: true,

maxDistance: parseFloat(pRadius),

query: {

$and:

[

{ type_id: {$in: pTypeIDArray } },

{ valid: true } ,

{ $or: [ { enddate: null }, { enddate: { $gte: new Date() } } ] }

]

},

}

},

{

$project : {

provider_id : 1

, providername: 1

, offer_id: 1

, title: 1

, description: 1

, additionalinfo: 1

, likecount: 1

, restrictions: 1

, imagepath: 1

, price: 1

, startdate: 1

, enddate: 1

, showrating: 1

, dist: 1

, logopath: 1

, _id: 0

}

},

{

$skip: Number(pStartIndex)

},

{

$limit: Number(pEndIndex)

},

]).exec().then(function(result){

fullfill(result);

}).catch(function(err){

reject(err);

});

});

The document has the following indexes defined:

[url removed, login to view]()

[

{

"v" : 1,

"key" : {

"_id" : 1

},

"name" : "_id_",

"ns" : "[url removed, login to view]"

},

{

"v" : 1,

"key" : {

"loc" : "2dsphere"

},

"name" : "loc_2dsphere",

"ns" : "[url removed, login to view]",

"background" : true,

"2dsphereIndexVersion" : 2

},

{

"v" : 1,

"key" : {

"loc" : "2d"

},

"name" : "loc_2d",

"ns" : "[url removed, login to view]",

"background" : true

}

]

The schema for the document is:

var OfferSchema = new Schema({

provider_id : { type: Number, required: true }

, providername : { type: String, required: true }

, showrating: { type: Boolean, default: false }

, offer_id: { type: Number, required: true }

, title: { type: String, required: true }

, description: { type: String, required: true }

, additionalinfo: { type: String }

, likecount: { type: Number, default: 0 }

, restrictions: [String]

, imagepath: { type: String, required: true }

, baseimage: { type: String, required: true }

, startdate: {type: Date }

, enddate: {type: Date }

, valid: { type: Boolean, required: true }

, loc: {

'type': { type: String, default: 'Point' },

//type: [Number], default: [0,0]

coordinates: [Number]

}

, price: { type: String }

, type_id: { type: Number, required: true }

, updatedate: { type: Date, required: true }

, logopath: { type: String }

, videourl: { type: String }

});

[url removed, login to view]({loc: '2dsphere'});

[url removed, login to view]('offers', OfferSchema);

You need to be mongoDB guru and have advance aggregation experience.

Znanja: NoSQL Couch in Mongo

Več: mongodb query php, php mongodb query, bad subdomain sql query prestashop fix, fix var _x3 _x3 _nsurls, fix bad subdomain sql query prestashop, bad subdomain sql query error fix, fix google custom var, fix bad subdomain sql query, mysql query mongodb php, mongodb mysql query, mongodb php query, mongodb query mysql, excel web query fix data position, fix mysql query error, mysql fix 2013 query, actionscript query string var, fix phplist database error 1146 query table

O delodajalcu:
( 9 mnenja ) Laguna Hills, United States

ID projekta: #11309739

1 freelancer ponuja za povprečno $24 na tem delu

$24 USD v 1 dnevu
(5 Ocen)
3.8