3

Our team is currently working on some killer ios location app that we fear "explode" in a good way, so we want to put effort thinking about scalability and Availability.

After we read that draw something is based on couchbase NoSQL, we scanned the couch base api (specifically the .net one) and found solutions to all of our app requirements except one, and we describe the scenario:

  1. Let's say we have order of 1,000,000 users around the world, with their location specified by longitude and latitude;
  2. We have a user circle range c: it's location (specified by longitude and latitude) and a radius rc
  3. We want to efficiently determine which of the users are in the circle.

If we write it in sql server as we did now it's something like this:

CREATE TABLE UserLocations
[UserId] [bigint] NOT NULL,
[CurrentLocation] [geography] NOT NULL

ALTER PROCEDURE sp_GetCurrentUsersInRange
@userPoint geography, 
@RangeInMeters int
AS
BEGIN

select  UserId from UserLocations
where @userPoint.STDistance(CurrentLocation) <= @RangeInMeters
and UserId <> @userId

END

But this is NoSQL, there are only keys (such as longitude key and latitude key), but we can’t fetch all the values and query them all in memory , can't we?

So the question to you is: Is there a way you know how to accomplish such thing in NoSQL?

Thank you

p.s. our related question in Stackoverflow: How to determine n locations inside a circle efficiently?

EDIT: Couchbase support had answered me! their answer as quoted:

"Our geo-spatial indexing is a feature being debuted in 2.0 (scheduled out later this year) as experimental and will move to fully supported in a later release. We are also in the process of building the necessary client-side interfaces for it, but there is nothing available at the moment. Lastly, the distance and bounding circle (among others) are features that we will develop as we move forward."

Community
  • 1
  • 1
ozba
  • 6,522
  • 4
  • 33
  • 40
  • More info about the Couchbase stuff is available at the Couchbase Forums: http://www.couchbase.com/forums/thread/question-regarding-geographic-queries – vmx May 13 '12 at 15:58

1 Answers1

3

I'm unaware of doing it with couchbase, but MongoDB has geospatial indexing.

http://www.mongodb.org/display/DOCS/Geospatial+Indexing

EDIT Looks like Couch has GeoSpatial as well, through GeoCouch. http://www.couchbase.com/docs/couchbase-geocouch-guide/

taylonr
  • 10,732
  • 5
  • 37
  • 66
  • Thanks! I even found a geo spatial example in MongoDB C# driver here: http://stackoverflow.com/questions/6993249/mongodb-geospatial-index-in-c-sharp But I still don't know yet if couch GeoSpatial is supported via the Couchbase Client Library: .NET (C#) 1.2 o_o – ozba Apr 30 '12 at 13:19
  • Couchbase geospatial indexing is not supported yet, but planned to be. See in my question EDIT. – ozba Apr 30 '12 at 15:34
  • Moving from Couch to Mongo isn't that big of a shift, they're both document stores. They have their own quirks, but it's a much easier transition than say MySql to Couch. – taylonr Apr 30 '12 at 16:27
  • we need to move from SQL Server to Couch or mongo DB – ozba Apr 30 '12 at 20:38