FAQ

[mongodb-user] using filter_geoNear in mongo rest

Marc
Jan 13, 2012 at 9:15 pm
Unfortunately, the REST interface only accepts strings and integers.
Therefore, the array [114.25,22.3] is interpreted as a string, as you
can see in the "query" document:
"query" : { "geoNear" : "mytable", "near" : "[114.25,22.3]" }

An attempt to perform a find operation with $near suffers from the
same issue:
http://localhost:28017/test/mytable/?filter_gps={$near:[114,22]}
"query" : { "gps" : "{$near:[114, 22]}" }
"{$near:[114, 22]}" is interpreted as a string.

For this reason, the REST interface is unable to run many commands.

There is an outstanding JIRA ticket to improve the REST interface:
SERVER-2030 - "Better REST api query"
https://jira.mongodb.org/browse/SERVER-2030
Unfortunately it is not scheduled for a specific release version.

Now the good news: There is a third-party REST interface for mongo
called Sleepy.Mongoose, which will run commands.

http://www.snailinaturtleneck.com/blog/2010/02/22/sleepy-mongoose-a-mongodb-rest-interface/

Once you have Sleepy.Mongoose up and running, you can execute a
geoNear command like so:
$ curl --data 'cmd={"geoNear" : "mytable", "near":[114.25,22.3]}'
'http://localhost:27080/mydatabase/_cmd'

Further documentation on how to perform database commands with
Sleepy.Mongoose may be found here:
https://github.com/kchodorow/sleepy.mongoose/wiki/Database-Commands

Hopefully this will be helpful for you.

--
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@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
reply

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›

2 users in discussion

Jason.Lee: 1 post Marc: 1 post