mongodb geospatial subquery in array, how to return the array element nearest to the query? -
when make query find subdocument nearest query make :
the query :
db.areas.findone( { 'coordinates.geoindex' : { $near : [ 2.364022, 48.896606 ] } } )
it return document containing array having nearest element query. i'd find nearest subelement.
for example query should find second array item "aubervilliers" first.
do think that's possible ?
the document style :
{ "_id" : objectid("5199335f6db079ede30000"), "commercial_name" : "paris area", "coordinates" : [ { "long_name" : "arcueil", "short_name" : "arcueil", "geoindex" : [ 2.334955, 48.80486 ] }, { "long_name" : "aubervilliers", "short_name" : "aubervilliers", "geoindex" : [ 2.384049, 48.912259 ] }, { "long_name" : "bagnolet", "short_name" : "bagnolet", "geoindex" : [ 2.4234589, 48.870364 ] }, { "long_name" : "boulogne-billancourt", "short_name" : "boulogne-billancourt", "geoindex" : [ 2.237803, 48.84325 ] }, { "long_name" : "charenton", "short_name" : "charenton-le-pont", "geoindex" : [ 2.4158559, 48.819918 ] } ...
sorry isn't possible, query chooses documents return , cannot shape how returned except inclusion , exclusion of fields via projection. need store data separate documents.
Comments
Post a Comment