How do I geo-search multiple models with ThinkingSphinx?

依然范特西╮ 提交于 2019-12-04 18:41:22

This is a late response, but better than nothing, hopefully:

When you're not searching on a specific model, Thinking Sphinx has no reference point for knowing what attributes are available, so you need to explicitly tell it the lat and long attributes to use:

ThinkingSphinx::Search.search('keywords',
  :geo => [
    degrees_to_radians(params[:lat].to_f),
    degrees_to_radians(params[:lon].to_f)
  ],
  :latitude_attr  => "latitude",
  :longitude_attr => "longitude"
)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!