Discussion:
Geospatial sorting
John Wood
2012-06-21 18:28:21 UTC
Permalink
Is it possible to order a list by distance from a specific location? I know
you can get everything within a specific square/circle etc., but I need to
get a paged list of locations that progressively gets further and further
away.

I guess I could do this using the polygon to create the area that I'm
probing and then sort those results manually... but it would be nice if I
could do this automatically from mongo in one query.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
Jenna
2012-06-21 21:57:30 UTC
Permalink
If you create a geospatial index on your data, you can return
documents near a certain location using the $near operaton. Assuming
the index is used, documents will be sorted by distance from the
specified point. Please see the documentation for more information:
http://www.mongodb.org/display/DOCS/Geospatial+Indexing
Post by John Wood
Is it possible to order a list by distance from a specific location? I know
you can get everything within a specific square/circle etc., but I need to
get a paged list of locations that progressively gets further and further
away.
I guess I could do this using the polygon to create the area that I'm
probing and then sort those results manually... but it would be nice if I
could do this automatically from mongo in one query.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
John Wood
2012-06-21 22:10:49 UTC
Permalink
Ah, I didn't notice the bit about it automatically sorting - thank you
that's great.
Post by John Wood
Is it possible to order a list by distance from a specific location? I
know you can get everything within a specific square/circle etc., but I
need to get a paged list of locations that progressively gets further and
further away.
I guess I could do this using the polygon to create the area that I'm
probing and then sort those results manually... but it would be nice if I
could do this automatically from mongo in one query.
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/***@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/***@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
Loading...