Re: geoNear

59 views
Skip to first unread message

Michael Klishin

unread,
Sep 19, 2012, 4:19:04 AM9/19/12
to Monger, a Clojure MongoDB driver


On Sep 19, 10:20 am, biscarch <avantdigita...@gmail.com> wrote:
> Has anyone run a geoNear command using Monger? My implementation seems to
> result in the near field being read as a command.
>
> Here is my command:
>
> {:geoNear "collection" :near 50 :test 430 :num 10}

Please post full code example (that includes the function call).

MK

biscarch

unread,
Sep 19, 2012, 7:39:38 AM9/19/12
to clojure...@googlegroups.com
Here is the full noir route and relevant requires:

(:require [clojure.data.json :as js]
              [monger.core :as mg]
              )

(defpage "/bars" []
  (let [bars (mg/command (mg/get-db "test") {:geoNear "bars" :near 50 :test 430 :num 10})]
  (response/status 200 (js/json-str bars))))

and the error returned from mongo (that makes it all the way back to curl):

{"serverUsed":"flame.mongohq.com\/ip:port","errmsg":"no such cmd: near","bad cmd":{"near":50,"test":430,"num":10,"geoNear":"bars"},"ok":0.0}%   

I was using :test 430 to check the ordering of parameters in the error. It is the same with or without it.

Michael Klishin

unread,
Sep 19, 2012, 8:19:13 AM9/19/12
to clojure...@googlegroups.com
2012/9/19 biscarch <avantdi...@gmail.com>

I was using :test 430 to check the ordering of parameters in the error. It is the same with or without it.

try with (sorted-map :geoNear "bars" :near 50 :test 430 :num 10)

--
MK


biscarch

unread,
Sep 19, 2012, 9:05:01 AM9/19/12
to clojure...@googlegroups.com
That worked wonderfully. Thank you.

Full command is now:
(mg/command (mg/get-db "test") (sorted-map :geoNear "bars" :near [50 50] :num 10))

On Tuesday, September 18, 2012 11:20:46 PM UTC-7, biscarch wrote:
Has anyone run a geoNear command using Monger? My implementation seems to result in the near field being read as a command.

Here is my command:

{:geoNear "collection" :near 50 :test 430 :num 10}

Michael Klishin

unread,
Sep 19, 2012, 9:26:53 AM9/19/12
to clojure...@googlegroups.com
2012/9/19 biscarch <avantdi...@gmail.com>

That worked wonderfully. Thank you.

Thank *you* for bringing this up. We will update the docs (and monger.command, monger.collection functions) to recommend

Vesa

unread,
Nov 18, 2014, 11:28:28 PM11/18/14
to clojure...@googlegroups.com
Hi,


On Wednesday, September 19, 2012 8:27:34 PM UTC+7, Michael Klishin wrote:
Thank *you* for bringing this up. We will update the docs (and monger.command, monger.collection functions) to recommend
and use sorted maps.

The example in [1] is (sorted-map geoNear db "bars" :near 50 :test 430 :num 10) which seems incorrect (geoNear, db)

[1] https://github.com/michaelklishin/monger/blob/ef539f48c8c6a880c7c4e0ced2eff7d4631a0cb6/src/clojure/monger/core.clj#L178


Michael Klishin

unread,
Nov 19, 2014, 10:15:17 AM11/19/14
to clojure...@googlegroups.com, Vesa
On 19 November 2014 at 15:12:54, Vesa (vesa.po...@leonidasoy.fi) wrote:
> The example in [1] is (sorted-map geoNear db "bars" :near 50
> :test 430 :num 10) which seems incorrect (geoNear, db)
>
> [1] https://github.com/michaelklishin/monger/blob/ef539f48c8c6a880c7c4e0ced2eff7d4631a0cb6/src/clojure/monger/core.clj#L178

It should be  , yes.
--
@michaelklishin, github.com/michaelklishin
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages