전달 된 좌표로부터 거리별로 정렬하여 위치를 검색해야합니다.스핑크스 사고 조사 문제
응용 프로그램/지수/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'
- 스핑크스 2.0.6 릴리스 (r3473, 2012년 10월 22일)
- thinking- 스핑크스 (3.0.1)
업데이트 :
팻 앨런 제안하지 : 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
정말 도움이 될만한 생각 스핑크스에 대해 충분히 알지 못합니다. 아마도'compat_sphinxql_magics = 1 '을 (또는 기존 라인을 0에서) sphinx.conf 파일에 추가 해보십시오. @geodist는 sphinxql의 나중 버전에서 지원되지 않으므로 레거시 모드를 다시 활성화해야합니다. – barryhunter
@barryhunter, 그것은 도움이되지 못했습니다. 하지만 고마워! –