Aggregation Framework
db.collection.aggregate(pipeline, options)mydb.mycollection.aggregate([
{‘$match’ : {‘$text’ : {‘$search’ : ‘ value ’}}},
{‘$sort’ : SON([(‘ field ’, 1)])}, # from bson.son import SON
{‘$project’ : {‘ field1 ’ : 1, ‘ field2 ’ : 1, ‘ field3 ’ : 0}}
])GeoNear
mydb.mycollection.aggregate([{
‘$geoNear’ : {
‘near’ : { type: ‘ value ’, ‘coordinates’: [ longtitude , latitude ] },
‘distanceField’ : ‘ stringvalue ’,
‘query: {key:value},
‘maxDistance’ : value
}}])Last updated
Was this helpful?