Skip to content

Instantly share code, notes, and snippets.

@maisnamraju
Last active May 14, 2018 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maisnamraju/e5ddd6688d8a15312f73dd933fca065d to your computer and use it in GitHub Desktop.
Save maisnamraju/e5ddd6688d8a15312f73dd933fca065d to your computer and use it in GitHub Desktop.
{
"_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"
]
}
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