Last active
May 14, 2018 14:38
-
-
Save maisnamraju/e5ddd6688d8a15312f73dd933fca065d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_id" : ObjectId("5af99f1f5b51a81520f620fa"), | |
"City" : "Jakarta", | |
"Name" : "Kisaku Japanese Restaurant", | |
"Street" : "", | |
"Street_Number" : "", | |
"Postal" : NumberInt(13960), | |
"Locality" : "", | |
"Country" : "Indonesia", | |
"Formatted_Address" : "Ujung Menteng; Cakung; East Jakarta City; Jakarta 13960; Indonesia", | |
"Google Maps link" : "http://maps.google.com/maps?&z=10&q=-6.184506+106.96832730000006&ll=-6.184506+106.96832730000006", | |
"Phone" : "", | |
"Website" : "", | |
"Keyword" : "sushi restaurant", | |
"Email" : "", | |
"location" : { | |
"type" : "Point", | |
"coordinates" : [ | |
106.968327, | |
-6.184506 | |
] | |
}, | |
"url" : "jakarta/kisaku-japanese-restaurant", | |
"tags" : [ | |
"sushi restaurant" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.collection('places').aggregate([ | |
{ | |
$geoNear: { | |
near: { type: "Point", coordinates: [Number(req.query.lng),Number(req.query.lat)] }, | |
distanceField: "distance", | |
maxDistance: 30 * 1000 , | |
includeLocs: "dist.location", | |
distanceMultiplier: 0.001, | |
spherical: true, | |
limit: 40 | |
} | |
}, | |
{ | |
$match: { | |
$and: [ | |
{ tags: { $in: [tagName] } }, | |
{ city: req.query.city } | |
] | |
}, | |
}, | |
{ $sort: { distance: 1 } }, | |
{ | |
$project: { | |
c: "$City", | |
i: "$url", | |
n: "$Name", | |
t: "$tags", | |
k: "$Keyword", | |
l: "$location.coorindates", | |
d: "$distance" | |
} | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment