2012-02-14 69 views
0

我寫這樣的查詢geo_near紅寶石不工作在軌道上與mongoid

Org.where( 'content.attribs.name'=> '菜', 'content.attribs.value'=>菜) .geo_near([ 'address.location.lng'=> LON, 'address.location.lat'=> LAT]:MAX_DISTANCE => DIST,:球形=>真,民:NUM_RESULTS)

我保存數據如下

[{ 「_id」:「4f37d63d3e4549126c000 001「,」地址「:{」_ id「:」4f37d63d3e4549126c000002「,」城市「:」尚蒂伊「,」國家「:null,」line1「:」13921 Lee Jackson Memorial Hwy「,」line2「:null,

「location」:{「lng」:38.893017,「lat」: - 77.428186},「phone1」:「703-378-1717」,「phone2」:null,「postal_code」:「20151」 :「VA」}「content」:{「_ id」:「4f37d63d3e4549126c000003」,

「attribs」:[{「_ id」:「4f37d63d3e4549126c000004」,「name」:「cuisine」,「value」墨西哥菜「},{」_ id「:」4f37d63d3e4549126c000005「,」name「:」cuisine「,」value「:」Tex Mex「}],」author「:null,

」content_type「:」menu「 「鏈接」:「http://www.anitascorp.com」,「org_type」:「餐廳」,「標題」:空},「名稱」:「安妮塔的新墨西哥餐廳」,「src_code」:「RESTAURANTDB」, 「S rc_id「:」308701「}

我無法使用geo_near獲取數據。

回答

0

SMS = SideMongo.where(隱藏:0).geo_near([lng.to_f,lat.to_f],MAX_DISTANCE:dis.to_i,單位: 「公里」 .to_sym,球形:真).sort_by {|! [R | r.geo [:distance]}