我需要按与传递坐标的距离排序来搜索位置。
应用程序/索引/location_index.rb
ThinkingSphinx::Index.define :location, :with => :active_record do
indexes :name
has latitude, longitude
end
尝试搜索:
> Location.search(:geo => [53.348962, 83.777988], :order => "@geodist DESC").size
ThinkingSphinx::SyntaxError: sphinxql: syntax error, unexpected USERVAR, expecting IDENT (or 5 other tokens) near '@geodist DESC LIMIT 0, 20; SHOW META'
> Location.search(:geo => [53.348962, 83.777988],:with => {"@geodist" => 0.0..5000.0}, :order => "@geodist DESC").size
ThinkingSphinx::SphinxError: sphinxql: only >=, <=, and BETWEEN floating-point filter types are supported in this version near '@geodist BETWEEN 0.0 AND 5000.0 AND sphinx_deleted = 0 ORDER BY @geodist DESC LIMIT 0, 20; SHOW META'
- Sphinx 2.0.6 版本(r3473;2012 年 10 月 22 日)
- 思考狮身人面像 (3.0.1)
更新:
Pat Allan 建议: Geodist 不再需要 @ 符号 - 所以请尝试以下操作:
Location.search(:geo => [53.348962, 83.777988], :order => "geodist DESC").size
Location.search(:geo => [53.348962, 83.777988],:with => {:geodist => 0.0..5000.0}, :order => "geodist DESC").size